官方安装方法 https://docs.docker.com/engine/installation/linux/ubuntu/
Ubuntu安装包 https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/
CentOS7安装包 https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
镜像仓库 https://hub.daocloud.io/repos
CentOS依赖包 http://mirrors.163.com/centos/7/os/x86_64/Packages/
更新rpm源 https://yum.dockerproject.org/repo/main/centos/7/Packages/
docker cloud https://docs.docker.com/docker-cloud/orgs/
docker mechine https://github.com/docker/machine
https://docs.docker.com/machine/
virtualbox https://www.virtualbox.org/wiki/Linux_Downloads
[nescafe@localhost ~]$ service docker start
Redirecting to /bin/systemctl start docker.service
sudo docker pull daocloud.io/library/java:openjdk-8u40-b22
openjdk-8u40-b22: Pulling from library/java
a3ed95caeb02: Pull complete
5274d3e5ed75: Pull complete
6fd31118c0f5: Pull complete
7e92ec83d37b: Pull complete
4f15000735fa: Pull complete
9ea8df248b9e: Pull complete
5b01510e96f0: Pull complete
Digest: sha256:f2ae4c27d2ce5f3c6a97693ef87270c5704348849308bc2d110479355d01ef2a
Status: Downloaded newer image for daocloud.io/library/java:openjdk-8u40-b22
#nescafe@ubuntu:~$ sudo docker pull centos
#nescafe@ubuntu:~$ sudo docker pull ubuntu
nescafe@ubuntu:~$ sudo docker pull frolvlad/alpine-oraclejdk8
nescafe@ubuntu:~/temp/dockerImagesTemp$ sudo docker images
[sudo] nescafe 的密码:
REPOSITORY TAG IMAGE ID CREATED SIZE
springconsumer latest 1db760c515f0 4 minutes ago 264 MB
docker-whale latest e56cecfcfff8 7 hours ago 275 MB
frolvlad/alpine-oraclejdk8 slim a1c742b93b8b 2 days ago 167 MB
ubuntu latest 6a2f32de169d 4 days ago 117 MB
centos latest a8493f5f50ff 10 days ago 192 MB
docker/whalesay latest 6b362a9f73eb 23 months ago 247 MB
daocloud.io/library/java openjdk-8u40-b22 0a5e1e22983a 2 years ago 815 MB
daocloud.io/library/ubuntu quantal 3e314f95dcac 2 years ago 172 MB
learn/tutorial latest a7876479f1aa 4 years ago 128 MB
docker run <相关参数> <镜像 ID> <初始命令>
-i:表示以“交互模式”运行容器
-t:表示容器启动后会进入其命令行
-v:表示需要将本地哪个目录挂载到容器中,
格式:-v <宿主机目录>:<容器目录>
#sudo docker run -i -t -v /home/nescafe/temp/dockerImagesTemp:/app a8493f5f50ff /bin/bash
nescafe@ubuntu:~/temp/spring_cloud_docker$ sudo docker build -t springconsumer .
docker run springconsumer
nescafe@ubuntu:~/temp/dockerImagesTemp$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0594fdb7007 springconsumer "sh -c 'java -jar ..." 3 minutes ago Up 3 minutes boring_chandrasekhar
nescafe@ubuntu:~/temp/spring_cloud_docker$ sudo docker rm a0594fdb7007 #springconsumer的容器
nescafe@ubuntu:~/temp/spring_cloud_docker$ sudo docker rmi 1db760c515f0 #springconsumer
#Dockerfile
FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD Spring_Cloud_Client_Consumer-1.4.5.RELEASE.jar app.jar
RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java -jar /app.jar" ]
#保存迁移镜像
nescafe@ubuntu:~/temp/spring_cloud_docker$ sudo docker save -o docker-image-springconsumer.tar.gz springconsumer:latest
root@ubuntu:/home/nescafe/temp/spring_cloud_docker# chmod 777 docker-image-springconsumer.tar.gz
root@ubuntu:/home/nescafe/temp/spring_cloud_docker# sudo docker load < docker-image-springconsumer.tar.gz
5922be4c6e3c: Loading layer [==================================================>] 48.91 MB/48.91 MB
448c94ba5593: Loading layer [==================================================>] 48.91 MB/48.91 MB
Loaded image: springconsumer:latest
#CentOS7离线安装docker
[root@localhost temp]# ls
docker-engine-17.04.0.ce-1.el7.centos.x86_64.rpm libcgroup-0.41-11.el7.x86_64.rpm libcgroup-pam-0.41-
11.el7.x86_64.rpm
docker-engine-selinux-17.04.0.ce-1.el7.centos.noarch.rpm libcgroup-devel-0.41-11.el7.x86_64.rpm libcgroup-tools-0.41-
11.el7.x86_64.rpm
[root@localhost temp]# rpm -ivh libcgroup-*
准备中... ################################# [100%]
软件包 libcgroup-0.41-11.el7.x86_64 已经安装
软件包 libcgroup-tools-0.41-11.el7.x86_64 已经安装
[root@localhost temp]# rpm -ivh docker-engine-selinux-17.04.0.ce-1.el7.centos.noarch.rpm
警告:docker-engine-selinux-17.04.0.ce-1.el7.centos.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 2c52609d: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:docker-engine-selinux-17.04.0.ce-################################# [100%]
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400.
restorecon: lstat(/var/lib/docker) failed: No such file or directory
警告:%post(docker-engine-selinux-17.04.0.ce-1.el7.centos.noarch) 脚本执行失败,退出状态码为 255
[root@localhost temp]# rpm -ivh docker-engine-
docker-engine-17.04.0.ce-1.el7.centos.x86_64.rpm docker-engine-selinux-17.04.0.ce-1.el7.centos.noarch.rpm
[root@localhost temp]# rpm -ivh docker-engine-17.04.0.ce-1.el7.centos.x86_64.rpm
警告:docker-engine-17.04.0.ce-1.el7.centos.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 2c52609d: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:docker-engine-17.04.0.ce-1.el7.ce################################# [100%]
[root@localhost temp]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@localhost temp]# docker -v
Docker version 17.04.0-ce, build 4845c56