Tag: dockerfile

优雅地停止Docker容器

我有一些麻烦了解如何我可以做一些清理当容器停止。 为了更容易,我准备了一个样本来重现问题。 这里是我的文件的内容: Dockerfile FROM opensuse:latest # Install tcsh (non-interactive mode) RUN zypper -n in tcsh # Create user RUN useradd -ms /bin/tcsh dummyuser # Set the user USER dummyuser # Change Working Dir WORKDIR /home/dummyuser # Copy entrypoint script COPY docker-entrypoint.sh $HOME # Starter Script ENTRYPOINT ["./docker-entrypoint.sh"] docker-entrypoint.sh #!/bin/tcsh echo "Starting" onintr cleanup # […]

如何赋予docker容器在映射卷上写入/ chmod权限?

我有一个Synology NAS,它有docker支持,并且想运行一些docker容器(我对Docker相当新颖)。 例如pocketmine-pm(但我相信我也有其他容器的写入问题)。 我在主机上创build了一个卷,并将其映射到容器设置中。 (而在Synologydocker设置的卷映射,我没有点击“只读”)。 根据Dockerfile,在容器中创build一个新的用户'pocketmine',并且该用户用于启动服务器。 用户似乎有用户ID 1000(新的Linux用户的第一个UID)。 容器也使用Entrypoint.sh脚本来启动服务器。 最初容器不能将文件写入映射的目录。 我不得不通过SSH进入主机“chown”UID 1000的目录: sudo chown 1000:1000 /volXy/docker/pocketminemp -R 之后,档案可以被下载和提取。 不幸的是,我无法从我的iOS设备连接到服务器。 服务器被列为“在线”,但连接失败,没有任何特定消息。 然后我检查了容器的日志,看到下面的条目(不知道这是否真的阻止了连接,但我会试试看): [*] Everything done! Run ./start.sh to start PocketMine-MP chown: changing ownership of '/pocketmine/entrypoint.sh': Operation not permitted chown: changing ownership of '/pocketmine/server.properties.original': Operation not permitted Loading pocketmine.yml… 显然容器不能chown它以前能够下载的文件。 有谁知道可以做些什么来解决这个问题? 我是否需要chmod映射卷,为什么我需要将目录切换到UID 1000(主机上不存在的用户) – 是不是有更好的方法来修复权限?

注册软件包时,本地pypi服务器告诉我403 Forbidden

我正在尝试部署一个pypi-server来托pipe我们的内部软件包。 我一直拉着我的头发在这个docker集装箱内的pypi的行为。 Dockerfile FROM python:3.5 RUN apt-get update RUN pip install –upgrade pip RUN pip install -U passlib pypiserver[cache]==1.2.0 RUN mkdir -p /src/pypi/packages EXPOSE 8080 ADD ./htpasswd /src/pypi/htpasswd CMD ["pypi-server", "-p 8080", "-P", "/src/pypi/htpasswd","/src/pypi/packages"] 很简单,对吧? 姐姐到docker文件当然有一个名为htpasswd文件包含用户名/密码对。 如果我在本地(在Docker外部的环境中)完成了docker文件中定义的步骤,然后执行上面定义的命令,它就可以工作了! 我可以注册它的包。 在外面运行的Pypi Dockerfile: python setup.py register -r local running register running egg_info writing top-level names to ah_model.egg-info/top_level.txt writing […]

Djangorest项目dockerfile

docker工人对我来说是全新的。 我有一个现有的Django Rest项目,其结构如下所示: 我的requirements.txt: django==1.8.8 djangorestframework markdown django-filter django-rest-auth django-cors-headers django-secure django-sslserver django-rest-auth[extras] 通常我创build一个虚拟环境>激活>执行pip install requirements.txt ,另外我需要easy_install mysql-python来开始。 我想dockerize这个项目。 有人可以帮我build立一个简单的docker文件这个项目?

在dockerfile中cachingPIP包

我正在尝试为我的python项目设置docker,该项目使用虚拟环境,并在requirements.txt定义了一些依赖关系。 我也设置了Dockerfile docker-compose ,它使用Dockerfile来使用命令build立我的项目图像Dockerfile docker-compose up –build 我的Dockerfile: FROM ubuntu:16.04 FROM python:3.5 MAINTAINER **** ADD . /core-proejct WORKDIR /core-project RUN pip3 install virtualenv RUN . /bin/activate RUN pip install -r requirements.txt 所以,每当我尝试构build映像时,它都会从requirements.txt安装所有的pip模块。 无论如何,我可以cachingpip模块,并在构build映像时使用caching版本。

新提交的Docker镜像的Dockerfile

我在我的系统中下载了一个Ubuntu操作系统的映像,并且在从映像中提交了3个映像之后(每个映像都有一个从映像之前的增量变化),现在我有了最终映像。 现在我想要这个最终图像的Dockerfile,以便我可以在容器的开始处包含像启动服务一样的命令。 我用过这个命令, sudo docker commit –change='CMD service apache2 start' 172d6dc34471 server_startup 在容器运行时启动apache服务。 这启动容器中的服务,但不进入容器内。 它只是启动Apache并退出到我的本地环境。 我想知道如何获得我的最终形象的Dockerfile,以便我可以包含启动命令。 我也尝试了这个docker文件从图像 ,但它不工作。 它只是抛出.sock文件丢失的错误。 我已经尝试了这个新的图像和我第一次下载的父图像。 任何帮助深表感谢。 谢谢。

无法使用MySQLWorkbench连接使用dockerfile构build的mysql

dockerfile是: FROM mysql ENV MYSQL_DATABASE=xxx ENV MYSQL_ROOT_PASSWORD=password ENV MYSQL_ROOT_HOST=172.17.0.1 EXPOSE 3306 我创build一个图像,它被执行,并在控制台的输出是: Initializing database 2017-06-04T21:45:27.614648Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details). 2017-06-04T21:45:28.165234Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-06-04T21:45:28.239707Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-06-04T21:45:28.268303Z 0 […]

入口与CMD结合

我花了一些时间来掌握ENTRYPOINT和CMD的区别。 在这种情况下,我正在做一些研究,所以即使这里的想法可能不是最好的,那更多的是要得到这个结果。 如果我理解一切正确,比如: ENTRYPOINT ["/bin/bash", "-l", "-c"] CMD ["node index.js"] 应该导致这个命令: /bin/bash -l -c node index.js 对? 我想要做的是为ENTRYPOINT点创build一个脚本,基本应该是这样的: #entry.sh #step 1 npm install #step 2 npm run watch & #step 3 compass watch & #step n #that line bothers me /bin/bash -l -c $* 所以我想完成的是:如果CMD改变了所有的“步骤1 -n”应该被执行,并且最终的CMD应该看起来像: /bin/bash -l -c node index.js 相反,我得到: node index.js: entry.sh: […]

在分离模式下在docker中运行python进程

我写了我的Python应用程序的Dockerfile。 要求是: 安装并启动mysql服务器。 以分离模式在屏幕上运行应用程序。 以下是我的Dockerfile: FROM ubuntu:16.04 # Update OS RUN apt-get update RUN apt-get -y upgrade # Install Python RUN apt-get install -y python-dev python-pip screen npm vim net-tools RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server python-mysqldb RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY requirements.txt /usr/src/app RUN pip install –no-cache-dir -r requirements.txt COPY src /usr/src/app/src […]

使用Webpack_Loader停滞Django

得到一堆错误的结论 “ImportError:没有名为webpack_loader的模块”。 我有一个Django应用程序创build,我正在尝试使用Gunicorn的Docker。 我的Dockerfile和start.sh位于另一个名为approot目录的根目录中。 在approot就是运行django-admin startproject所期望的一切。 我的wsgi.py文件位于approot中的一个名为app的目录中。 这是我的… requirements.txt: Django>=1.8 gunicorn==19.6.0 Dockerfile: #Dockerfile # FROM directive instructing base image to build upon FROM python:2-onbuild # COPY startup script into known file location in container COPY start.sh /start.sh # EXPOSE port 8000 to allow communication to/from server EXPOSE 8000 # CMD specifies the command to execute […]