macOS,Dockerfile挂载一个文件夹不能改变locale

我试图装载一个文件夹与我的docker文件,而不是在构build复制。 我们使用git进行开发,并且我不想在每次更改testing时重新生成映像。

我的docker文件现在是这样的

#set base image FROM centos:centos7.2.1511 MAINTAINER Alex <alex@app.com> #install yum dependencies RUN yum -y update \\ && yum -y install yum-plugin-ovl \ && yum -y install epel-release \ && yum -y install net-tools \ && yum -y install gcc \ && yum -y install python-devel \ && yum -y install git \ && yum -y install python-pip \ && yum -y install openldap-devel \ && yum -y install gcc gcc-c++ kernel-devel \ && yum -y install libxslt-devel libffi-devel openssl-devel \ && yum -y install libevent-devel \ && yum -y install openldap-devel \ && yum -y install net-snmp-devel \ && yum -y install mysql-devel \ && yum -y install python-dateutil \ && yum -y install python-pip \ && pip install --upgrade pip # Create the DIR #RUN mkdir -p /var/www/itapp # Set the working directory #WORKDIR /var/www/itapp # Copy the app directory contents into the container #ADD . /var/www/itapp # Install any needed packages specified in requirements.txt #RUN pip install -r requirements.txt # Make port available to the world outside this container EXPOSE 8000 # Define environment variable ENV NAME itapp # Run server when the container launches CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] 

ive注释掉itapp Django文件的创build和复制,因为我想装入它们(我是否需要先重build它?)

那么我的安装命令是

 docker run -it -v /Users/alex/itapp:/var/www/itapp itapp bash 

我现在得到一个错误:

 bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory 

而dev实例不运行。

我怎么也将工作目录设置为我在运行时安装的卷?

试试这个命令。 docker run -w WORKDIR选项设置容器内的工作目录。

docker run -d -v /Users/alex/itapp:/var/www/itapp -w /var/www/itapp itapp

此外,您将映射您的容器端口到您的主机端口,以便能够访问,例如,从浏览器到您的应用程序。

为此,请使用以下命令。

docker run -d -p 8000:8000 -v /Users/alex/itapp:/var/www/itapp -w /var/www/itapp itapp

在此之后,您的应用程序应该在localhost:8000运行