# 使配置生效
systemctl daemon-reload
# 启动docker服务
service docker start
然后运行之前的命令
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
friendlyhello latest a8cde448a919 8 minutes ago 131MB
python 2.7-slim 413ee88c678e 2 weeks ago 120MB
hello-world latest fce289e99eb9 7 weeks ago 1.84kB
怎么多了一个python的镜像?
运行app
# -p 把机器的4000端口和容器的80端口连在一起
docker run -p 4000:80 friendlyhello
接下来,在后台运行app
# -d 代表后台运行
docker run -d -p 4000:80 friendlyhello
使用命令查看
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7520f7d9f2b friendlyhello "python app.py" 33 seconds ago Up 32 seconds 0.0.0.0:4000->80/tcp friendly_easley