【发布时间】:2018-11-12 19:43:12
【问题描述】:
-自动安装泊坞窗。
-获取 3 个 docker 镜像(Apache、Nginx、MariaDB)。
-创建docker-compose.yml文件并进行配置。
-服务应该可以工作:Apache:port 8080 Nginx:port 80 MariaDB:port 4000.
#!bin/bash
sudo yum -y update
sudo tee >/etc/yum.repos.d/docker.repo <<-EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
sudo yum search docker-engine
sudo yum install -y docker-engine
sudo systemctl enable docker.service && systemctl start docker.service
sudo yum -y install epel-release
sudo yum -y install python-pip
sudo pip install docker-compose
sudo tee >/home/ash/docker_project/Dockerfile <<-EOF
FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
EOF
cd /home/ash/docker_project
sudo tee >/home/ash/docker_project/docker-compose.yml <<-EOF
version: '3'
services:
apache:
image: httpd:2.4
ports:
- "8080:8080"
volumes:
- ./src:/usr/local/apache2/htdocs
web:
image: nginx
volumes:
- ./mysite.template:/etc/nginx/conf.d/mysite.template
ports:
- "80:80"
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d && nginx -g 'daemon off;'"
db:
image: mariadb
ports:
- "4000:4000"
EOF
docker-compose up -d
看起来脚本运行正常,终端没有错误所以我的问题是为什么我在 localhost:8080 上看不到 apache 的起始页,与 nginx 和 MariaDB 一样?
所有输出都很长,但这里是主要内容
Starting docker_project_apache_1 ... done
Starting docker_project_web_1 ... done
Starting docker_project_db_1 ... done
当我运行docker images 时,我看到了这个列表:
REPOSITORY TAG IMAGE ID CREATED
bitnami/apache latest 569eec9f6f5c 4 days ago
mariadb latest 4828ff028cad 8 days ago
nginx latest ae513a47849c 4 weeks ago
httpd 2.4 fb2f3851a971 4 weeks ago
【问题讨论】:
-
你启动 apache 了吗?
标签: bash docker centos docker-compose