Deni Bertovic
https://denibertovic.com
https://github.com/denibertovic
Use Boot2Docker!
user@host:/$ docker login
user@host:/$ docker pull denibertovic/postgres
user@host:/$ docker run -d -t denibertovic/postgres
user@host:/$ docker run -i -t debian /bin/bash
user@host:/$ docker run -d -t postgres
user@host:/$ docker run -d -t postgres:9.3
user@host:/$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
d03ba4afb47c debian:7.5 /bin/bash 10 seconds ago Up 9 seconds
user@host:/$ docker logs d03ba4afb47c
user@host:/$ docker stop d03ba4afb47c
user@host:/$ docker kill d03ba4afb47c
user@host:/$ docker start d03ba4afb47c
user@host:/$ docker run -i -t debian /bin/bash
root@container:/$ apt-get install postgresql-9.3
user@host:/$ docker ps
user@host:/$ docker commit <CID> username/postgresql
user@host:/$ docker login
user@host:/$ docker push username/postgresql
co-worker@workstation2:/$ docker pull username/postgresql
FROM debian:wheezy
ENV DEBIAN_FRONTEND noninteractive
...
RUN apt-get -qq update
RUN apt-get -qq -y install postgresql-9.3 \
postgresql-client-9.3 postgresql-contrib-9.3
ADD postgresql.conf /etc/postgresql/9.3/main/postgresql.conf
...
CMD /usr/local/bin/start_postgres.sh
user@host:/$ docker build -t postgres .
user@host:/$ docker run -d -t postgresql
user@host:/$ psql -Upostgres -h localhost \
-c"CREATE DATABASE mydb WITH OWNER myuser;"
user@host:/$ python manage.py syncdb
user@host:/$ docker run -d -p 5432:5432 -t postgresql
"-p host_port:container_port"
user@host:/$ docker run -d -p 5432:5432 \
-v `pwd`/data:/var/lib/postgresql \
-t postgresql
"-v host_dir:container_dir"
user@host:/$ docker run -d --name pg -t postgresql
user@host:/$ docker run -d -p 8000:8000 \
--link pg:database -t django_app
"--link pg:database"
root@f9e4e78c60c6:/$ cat /etc/hosts
172.17.0.9 database
root@f9e4e78c60c6:/# export
DATABASE_PORT="tcp://172.17.0.9:5432"
DATABASE_PORT_5432_TCP="tcp://172.17.0.9:5432"
DATABASE_PORT_5432_TCP_ADDR="172.17.0.9"
DATABASE_PORT_5432_TCP_PORT="5432"
DATABASE_PORT_5432_TCP_PROTO="tcp"
https://github.com/docker/fig
web:
image: django-webapp
command: python app.py
links:
- db
- redis
- memcached
ports:
- "8000:8000"
db:
image: denibertovic/postgres
redis:
image: username/redis
memcached:
image: otheruser/memcahced
# THEN RUN
fig up