运行一个新容器
任务
你的任务很简单:
- 基于
docker/getting-started
镜像运行一个 Docker 容器。
要求
要完成这个挑战,你必须:
- 使用
docker run
命令启动容器。
- 使用镜像
docker/getting-started
。
- 在
~/project
目录下执行命令。
示例
当你成功运行容器时,你应该会看到一些关于 Docker 的信息输出。
如果你看到关于 /docker-entrypoint.d/
目录不为空的警告信息,不用担心。
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/10/29 09:26:17 [notice] 1#1: using the "epoll" event method
2024/10/29 09:26:17 [notice] 1#1: nginx/1.23.3
2024/10/29 09:26:17 [notice] 1#1: built by gcc 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4)
2024/10/29 09:26:17 [notice] 1#1: OS: Linux 5.15.0-56-generic
2024/10/29 09:26:17 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/10/29 09:26:17 [notice] 1#1: start worker processes
2024/10/29 09:26:17 [notice] 1#1: start worker process 31
2024/10/29 09:26:17 [notice] 1#1: start worker process 32
你可以打开一个新的终端窗口,使用 docker ps
命令来验证容器是否正在运行。
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f3f3b3b3b3b3 docker/getting-started "/docker-entrypoint.…" 1 minute ago Up 1 minute 80/tcp festive_mendel
注意:在点击 Continue 按钮之前,请不要退出终端。