demo、scaffold
create a folder named mysql
in repo directory
$ docker-compose up
if you can see below, it success
ht_server | [2018-04-19 03:14:20 +0000] [11] [INFO] Starting gunicorn 19.6.0
ht_server | [2018-04-19 03:14:20 +0000] [11] [INFO] Listening at: http://0.0.0.0:8000 (11)
ht_server | [2018-04-19 03:14:20 +0000] [11] [INFO] Using worker: sync
ht_server | [2018-04-19 03:14:20 +0000] [14] [INFO] Booting worker with pid: 14
host connect docker database with
host:127.0.0.1
port:8009
username:ht
password:ht
database:ht
-
docker-compose.yml line 38
django_example.wsgi
need same asdjango_example/wsgi.py
-
django_example/settings.py
ALLOWED_HOSTS、DATABASES
-
show running containers
$ docker ps
-
show all containers
$ docker ps -a
-
show downloaded docker images
$ docker images
-
Run a command in a new container
$ docker run --rm --name=container_name -it dockerdjango_web sh
$ exit
orctrl+d
to back to your host terminal -
Run a command in a running container
$ docker exec -it bf72189a3c51 sh
you can find like
bf72189a3c51
in$ docker ps
as CONTAINER ID -
create customed image with Dockerfile
$ cd docker-djangno $ docker build --rm -t pymysqlclient . # point means current directory $ docker images # check
-
发布镜像到docker hub
$ docker login # login to your docker hub $ docker tag dockerdjango_web dmltzy/dockerdjango $ docker images # check $ docker push dmltzy/dockerdjango # like git push
-
clear all containers
$ docker ps -a | awk 'NR>1 { print $1 }' | xargs docker rm
-
delete specific images
$ docker images | grep 'dockerdjango_web' | awk '{ print $3 }' | xargs docker rmi