[root@localhost compose]# cat docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "8888:80"
[root@localhost compose]# cat Dockerfile
FROM centos:7
MAINTAINER xy
RUN yum install -y httpd php php-gd php-mysql;systemctl enable httpd.service
RUN echo "<?php phpinfo()?>" > /var/www/html/index.php
EXPOSE 80
[root@localhost compose]# docker-compose up
---> d45344adbd48
Step 6/6 : EXPOSE 80
---> Running in 8ba263e41682
Removing intermediate container 8ba263e41682
---> b826f2af0a7c
Successfully built b826f2af0a7c
Successfully tagged compose_web:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating compose_web_1 ...
Creating compose_web_1 ... done
Attaching to compose_web_1
compose_web_1 exited with code 0
[root@localhost compose]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost compose]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
69675d705d29 compose_web "/bin/bash" 14 seconds ago Exited (0) 14 seconds ago compose_web_1
54794397b730 6d53ff0be550 "/bin/sh -c 'yum ins …" 2 hours ago Exited (1) 2 hours ago
[root@localhost compose]# docker-compose ps
Name Command State Ports
------------------------------------------
compose_web_1 /bin/bash Exit 0
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.