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
运行
- 将http请求redirect到django nginx服务器上的https时,AWR ALB运行状况检查失败
- docker-compose不下载requirements.txt文件的附加内容
- Docker-compose找不到.env文件
- Docker – “127.0.0.1”不是有效的端口 – Django
- 使用Django和Postgres在AWS上生产Docker:
- Kubernetes + MySQL:在Kubernetes容器中创build自定义数据库和用户
- 在Docker容器中安装anaconda时出错
- Postgres到Ubuntu的Docker容器链接不工作
- 连接到Docker容器上的PostgreSQL数据库