Docker compose安装和使用
由官方提供:
root@ubuntu18_04:~#
curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
root@ubuntu18_04:~# chmod +x /usr/local/bin/docker-compose
root@ubuntu18_04:~# docker-compose --version
docker-compose version 1.24.1, build 4667896b
Docker compose使用:
创建docker-compose.yml文件
root@ubuntu18_04:~# vim docker-compose.yml
version: '3' services: web: build: . ports: - "8888:80"
端口:本机的8888映射到容器的80
创建Dockerfile文件
root@ubuntu18_04:~#vim Dockerfile
FROM centos:6 MAINTAINER wangmaoquan RUN yum install -y httpd php php-gd php-mysql RUN echo "<?php phpinfo()?>" > /var/www/html/index.php CMD ["/usr/sbin/httpd","-D","FOREGROUND"] EXPOSE 80
构建镜像
root@ubuntu18_04:~# docker-compose up