Oct 26 19:38:40 linuxprobe.org docker-current[3762]: time="2016-10-26T19:38:40.568058527+08:00" level=info msg="Docker daemon" commit=cb079f6-unsupported execdriver=native-0.2 graphdriver=devicemapper version=1.10.3
Oct 26 19:38:40 linuxprobe.org docker-current[3762]: time="2016-10-26T19:38:40.572491688+08:00" level=info msg="API listen on /var/run/docker.sock"
Oct 26 19:38:40 linuxprobe.org systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
下载官方镜像并创建一个Container,并在Container中输出“Welcome to the Docker World”
[root@linuxprobe ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
08d48e6f1cff: Pull complete
Digest: sha256:b2f9d1c0ff5f87a4743104d099a3d561002ac500db1b9bfa02a783a46e0d366c
Status: Downloaded newer image for docker.io/centos:latest
[root@linuxprobe ~]# docker run centos /bin/echo "Welcome to the Docker World"
Welcome to the Docker World
使用“i”和“t”选项连接到Container的交互会话,如下所示。如果从Container会话退出,则Container的进程完成
[root@linuxprobe ~]# docker run -i -t centos /bin/bash
[root@82699d79557c /]# uname -a
Linux 82699d79557c 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@82699d79557c /]# exit
exit
[root@linuxprobe ~]# #back如果从容器会话中退出并保持容器的进程,请按Ctrl + p和Ctrl + q键
[root@linuxprobe ~]# docker run -i -t centos /bin/bash
[root@a05c7fd0a54f /]# [root@linuxprobe ~]#
[root@linuxprobe ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a05c7fd0a54f centos "/bin/bash" 24 seconds ago Up 23 seconds trusting_fermat
[root@linuxprobe ~]# docker attach a05c7fd0a54f # connect docekr process
[root@a05c7fd0a54f /]# [root@linuxprobe ~]# docker kill a05c7fd0a54f # kill docker process
a05c7fd0a54f
[root@linuxprobe ~]# docker ps # 查看运行的docker服务
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Docker:添加镜像
在容器中添加镜像文件
例如,使用更新官方映像安装httpd,并将其添加为容器的新映像。该容器是在每次执行docker run命令时生成的,因此添加最新执行的容器如下
[root@linuxprobe ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 0584b3d2cf6d Less than a second ago 196.5 MB
# start a Container and install httpd
[root@linuxprobe ~]# docker run centos /bin/bash -c "yum -y update; yum -y install httpd"










