0
我正在为Symfony开发的基础Docker容器工作。我正在使用Docker Toolset for Windows。这里是我的Dockerfile:码头集装箱运行不正常
FROM centos:6.7
MAINTAINER Reynier Perez <[email protected]>
# basic env fix
ENV TERM xterm
# Install REMI and EPEL repos
RUN yum update -y
RUN yum install -y mc wget yum-utils htop nano curl git
RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm \
&& wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm \
&& rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
RUN yum-config-manager --enable remi-php70
RUN yum install -y php \
php-common \
php-cli \
php-gd \
php-intl \
php-mbstring \
php-mcrypt \
php-opcache \
php-pdo \
php-pear \
php-pecl-apcu \
php-imagick \
php-pecl-xdebug \
php-xml \
php-mysqlnd \
php-soap \
php-pdo-dblib
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
RUN curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony
# Configure Services
# Create a copy of default files and remove them
# Apache
RUN cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.default
RUN rm -f /etc/httpd/conf/httpd.conf
ADD httpd.conf /etc/httpd/conf/
# Add default VirtualHost
ADD vhost.conf /etc/httpd/conf.d/
#PHP
RUN cp /etc/php.ini /etc/php.ini.default
RUN rm -f /etc/php.ini
ADD php.ini /etc/
# Add PHP info default script
ADD info.php /var/www/html
# Setup permissions
RUN chown -R apache:root /var/www/html && \
find /var/www/html -type d -print0 | xargs -0 chmod 2775 && \
find /var/www/html -type f -print0 | xargs -0 chmod 0664
# Mount Volumes
VOLUME /var/www/html
WORKDIR /var/www/html
EXPOSE 80
CMD service httpd restart
当我建立一个使用机器:
docker build --tag=symfony-dev .
我得到这个消息:
Successfully built c7bc46e1f84c
SECURITY WARNING: You are building a
Docker image from Windows against a non-Windows Docker host. All files
and directories added to build context will have '-rwxr-xr-x'
permissions. It is recommended to double check and reset permissions
for sensitive files and directories.
下一步是使用运行容器:
docker run symfony-dev
然后我试着看对于该容器中的信息:
docker inspect symfony-dev
而且我得到了这样的JSON:
[
{
"Id": "sha256:c7bc46e1f84c6d1a543c515d134184486dcb0e3e81c81f269ff1bb10791a3c9e",
"RepoTags": [
"symfony-dev:latest"
],
"RepoDigests": [],
"Parent": "sha256:db8021c4307e547ae7fee4afd3b964e72fde6422dbb8a5292b4bf441beb7d0b4",
"Comment": "",
"Created": "2016-04-02T02:16:45.891399606Z",
"Container": "e02be1ee3e12ef79bff0c0bbb7b7751f7368d5c06872df37a58439d21d69d57f",
"ContainerConfig": {
"Hostname": "72ba20be3774",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"/bin/sh\" \"-c\" \"service httpd restart\"]"
],
"ArgsEscaped": true,
"Image": "sha256:db8021c4307e547ae7fee4afd3b964e72fde6422dbb8a5292b4bf441beb7d0b4",
"Volumes": {
"/var/www/html": {}
},
"WorkingDir": "/var/www/html",
"Entrypoint": null,
"OnBuild": [],
"Labels": {
"License": "GPLv2",
"Vendor": "CentOS"
}
},
"DockerVersion": "1.10.3",
"Author": "Reynier Perez \[email protected]\u003e",
"Config": {
"Hostname": "72ba20be3774",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"Cmd": [
"/bin/sh",
"-c",
"service httpd restart"
],
"ArgsEscaped": true,
"Image": "sha256:db8021c4307e547ae7fee4afd3b964e72fde6422dbb8a5292b4bf441beb7d0b4",
"Volumes": {
"/var/www/html": {}
},
"WorkingDir": "/var/www/html",
"Entrypoint": null,
"OnBuild": [],
"Labels": {
"License": "GPLv2",
"Vendor": "CentOS"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 756378663,
"VirtualSize": 756378663,
"GraphDriver": {
"Name": "aufs",
"Data": null
}
}
]
但哪一个IP地址?我如何到达那个容器上的Apache?如果我运行命令ps如下:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
我没有看到任何容器运行,为什么?我在这里错过了什么?
UPDATE
继@ cricket_007建议,我已经在官方Dockerfile添加httpd_foreground
作为Apache和现在我看到的容器中运行,如果我跑docker ps
但我仍然有几个问题:
- 如果我运行容器进入bash作为
docker run -it --name=symfony symfony-dev bash
我得到这个错误:new state of nil is invalid
,我不知道如何解决。 - 在另一边,我看到172.17.0.2的IP地址,但我不能达到它作为Apache的意义
http://172.17.0.2/info.php
我有几个可疑的有关firewalld和/或SELinux的,但我不知道
我可以就这两个问题提供一些建议吗?
你的意思是添加'RUN tailf/etc/http/logs/XXXXXX.log'? – ReynierPM
不作为RUN,不。作为CMD –
实际上,Apache官方镜像使用'exec httpd -DFOREGROUND',这里是CMD中使用的脚本https://github.com/docker-library/httpd/blob/bc72e42914f671e725d85a01ff037ce87c827f46/2.4/httpd-foreground –