若是操做系統使用debian/deepin/ubuntu系列,安裝docker-ce(社區版本,相對還有docker-ee),能夠採用aliyun的腳本安裝:html
curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -
1.aliyun鏡像網站 https://dev.aliyun.com/search.html 2.docker hub https://hub.docker.com/java
針對Docker客戶端版本大於1.10的用戶,您能夠經過修改daemon配置文件/etc/docker/daemon.json來使用加速器:redis
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://30ied0wq.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
啓動/中止docker服務:systemctl docker start/stop 查看docker鏡像列表: docker images 查看docker容器列表: docker ps/docker ps -aq 刪除容器: docker rm [容器id]/docker rm $(docker ps -aq) 刪除鏡像: docker rmi 登錄:docker login --username=用戶id 地址 拉取鏡像:docker pull 導出鏡像:docker export 容器id > *.tar 導入鏡像:docker load < *.tar 標籤: docker tag 鏡像id 標籤或與倉庫地址相同名字:版本 提交到倉庫:docker push 倉庫地址:[鏡像版本號] 容器保存到鏡像:docker commit 容器id 標籤 進入容器: docker exec -it 容器id /bin/bash(/bin/sh或bash) 啓動鏡像:docker run -v 本地目錄:映射目錄 -p 容器端口:主機端口 鏡像id /bin/bash(/bin/sh或bash) 固然還有其餘參數,能夠查找手冊
後續補充spring
舉例:docker
1.docker search mongo 2.docker pull mongo:3.2 3.docker run -p 27017:27017 -v $PWD/db:/data/db -d mongo:3.2 4.docker run -it mongo:3.2 mongo --host 172.17.0.1 5.docker exec -it mongo /bin/bash
http://www.runoob.com/docker/docker-install-redis.htmljson
ubuntu vim /etc/default/dockerubuntu
DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"
centos: vim /lib/systemd/system/docker.servicevim
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
在springcloud中使用Docker,結合maven使用Dockerfile文件,首先在pom上添加centos
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- tag::plugin[] --> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.4.3</version> <configuration> <imageName>${docker.image.prefix}/${project.artifactId}</imageName> <dockerDirectory>src/main/docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> <!-- end::plugin[] --> </plugins> </build>
修改application.yml文件bash
server: port: 8761 eureka: instance: prefer-ip-address: true client: registerWithEureka: false fetchRegistry: false
IntellijIdea的Module中添加Dockerfile文件,與pom.xml所在目錄同級,但有個問題沒仔細研究,在編譯過程不會自動拷貝到eureka-1.0-SNAPSHOT.jar生成目錄下,手動拷貝一下就行。
FROM frolvlad/alpine-oraclejdk8:slim VOLUME /tmp ADD eureka-1.0-SNAPSHOT.jar app.jar #RUN bash -c 'touch /app.jar' ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] EXPOSE 10000
進入命令行,cd到pom.xml所在目錄
mvn clean mvn package docker:build
解決當前用戶沒有docker訪問權限問題
sudo groupadd docker sudo gpasswd -a ${USER} docker sudo service docker restart或sudo systemctl restart docker su root docker ps
Shipyard安裝
curl -sSL https://shipyard-project.com/deploy | bash -s