Deni Bertovic
initeQ d.o.o.
denibertovic.com
user@host:/$ docker pull postgres
user@host:/$ docker run -d -p 5432:5432 postgres
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
FROM debian:wheezy
ENV DEBIAN_FRONTEND noninteractive
...
RUN apt-get -qq update && 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 username/postgres .
user@host:/$ docker login
user@host:/$ docker push username/postgresql
co-worker@workstation2:/$ docker pull username/postgresql
https://docs.docker.com/compose/
# docker-compose.yml
db:
image: postgres:9.3
ports:
- "5432:5432"
web:
build: ./
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./:/code
links:
- db
ports:
- "8000:8000"
root@web:/$ cat /etc/hosts
172.17.0.9 db
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"
# Dockerfile
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements /code/requirements
RUN pip install -r /code/requirements/dev.txt
"docker-compose up" and do hotfix in 3 minutes, push to github, deploy
IMAGE_NAME="denibertovic/myimage"
## Build image from Dockerfile.
build:
docker build --rm -t $(IMAGE_NAME) .
## Push image to hub
push:
docker push $(IMAGE_NAME)
## Run container with default command.
run: build_env
@docker run -it \
--log-driver=syslog \
--env-file=/tmp/envfile \
$(IMAGE_NAME)
## Spawn a bash prompt in a container.
bash: build_env
@docker run -it \
--log-driver=syslog \
--env-file=/tmp/env \
$(IMAGE_NAME) /bin/bash
Use Docker Toolbox!
https://www.docker.com/toolbox
- name: redis container
docker:
name: myredis
image: redis
command: redis-server --appendonly yes
state: started
expose:
- 6379
The last 6+ slides are ideas for future talks you should submit...
Docker Networking Plugins, Docker storage drivers...
Questions