django - Why does CMD never work in my Dockerfiles? -
i have few dockerfiles cmd doesn't seem run. here example (all way @ bottom).
########################################################## # set base image ansible ubuntu:16.10 # install ansible, python , related deps # run apt-get -y update && \ apt-get install -y python-yaml python-jinja2 python-httplib2 python-keyczar python-paramiko python-setuptools python-pkg-resources git python-pip run mkdir /etc/ansible/ run echo '[local]\nlocalhost\n' > /etc/ansible/hosts run mkdir /opt/ansible/ run git clone http://github.com/ansible/ansible.git /opt/ansible/ansible workdir /opt/ansible/ansible run git submodule update --init env path /opt/ansible/ansible/bin:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin env pythonpath /opt/ansible/ansible/lib env ansible_library /opt/ansible/ansible/library run apt-get update -y run apt-get install python -y run apt-get install python-dev -y run apt-get install python-setuptools -y run apt-get install python-pip run mkdir /ansible/ workdir /ansible copy ./ansible ./ workdir / run ansible-playbook -c local ansible/playbooks/installdjango.yml env projectname testwebsite ################## setup directory structure ###################### workdir /home cmd ["django-admin" "startproject" "$projectname"] expose 8000
if build , run container, can manually run django-admin startproject $projectname , create new project expected, cmd in dockerfile not seem doing , happening other dockerfiles there's must not getting.
entrypoint
, cmd
defines default command docker runs when starts container, not when image built. when entrypoint
isn't defined, run value of cmd
. otherwise, cmd
becomes args entrypoint
. when run image, can override value of cmd
passing args after container name.
so, in example above, cmd
may defined anything, when run container docker run -it <imagename> /bin/bash
, override value of cmd
, replace /bin/bash. run defined value of cmd
, need run container docker run <imagename>
.
Comments
Post a Comment