2016-11-18 83 views
0

如果我運行一個容器(同時嘗試ubuntu和debian),它在後臺運行正常,但是當我嘗試執行docker run name -p 80:8080時出現以下錯誤:運行時Docker OSX端口映射錯誤:exec

docker: Error response from daemon: invalid header field value 

「OCI運行時錯誤:container_linux.go:247:啓動容器進程 引起的\」 EXEC:\\ 「 - p \\」:在$ PATH \ 「\ n」 找不到可執行文件。

這裏是我的dockerfile:

FROM ubuntu:latest 
MAINTAINER Phil Palmieri 

# Install apache, PHP, and supplimentary programs. openssh-server, curl, and lynx-cur are for debugging the container. 
RUN apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install \ 
    apache2 php7.0 php7.0-mysql libapache2-mod-php7.0 curl lynx-cur 

# Enable apache mods. 
RUN a2enmod php7.0 
RUN a2enmod rewrite 

# Update the PHP.ini file, enable <? ?> tags and quieten logging. 
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini 

# Manually set up the apache environment variables 
ENV APACHE_RUN_USER www-data 
ENV APACHE_RUN_GROUP www-data 
ENV APACHE_LOG_DIR /var/log/apache2 
ENV APACHE_LOCK_DIR /var/lock/apache2 
ENV APACHE_PID_FILE /var/run/apache2.pid 

# Expose apache. 
EXPOSE 80 

# Copy this repo into place. 
ADD . /var/www/site 

# Mount the volume for dev 
VOLUME [".:/var/www/site"] 

# Update the default apache site with the config we created. 
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf 

# By default start up apache in the foreground, override with /bin/bash for interative. 
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] 
+0

請粘貼您嘗試運行與容器的準確命令。 –

+0

Works:docker run -it -d abbvie/wow17:1.0 –

+0

無法正常運行docker run -it -d abbvie/wow17:1.0 -p 8080:80 –

回答

3

你的情況適當docker run看起來是這樣的:

docker run -i -d -p 80:8080 abbvie/wow17:1.0

+0

我以爲你需要它的標誌,如果你想連接到它 –

+0

你只需要'-i'如果你的容器沒有命令退出。 –

+0

@PhilPalmieri在[docs](https://docs.docker.com/engine/reference/run/#/detached-vs-foreground)中,前景與背景有很好的解釋。您可能也會發現這個答案有幫助[碼頭附加和碼頭執行程序之間的區別](http://stackoverflow.com/questions/30960686/difference-between-docker-attach-and-docker-exec/30962120#30962120) – R0MANARMY