Docker (Legacy)


getting started

docker deals with containers, docker-compose deals with services.

codeschool

  1. http://campus.codeschool.com/courses/try-docker/level/1/section/1/containers--images

docker-compose

  1. http://stackoverflow.com/a/35585573/3632318

.docker-compose.yml file lists services along with their images, commands and volumes (= mounted directories).

service is used to run command within specified image, service is run by 1+ containers.

for docker-compose commands to work .docker-compose.yml file must be present in current or one of parent directories.

docker

tips

debugging inside container

this is just one way and probably not the most efficient one:

ping another container

  1. https://docs.docker.com/v17.09/engine/userguide/networking

Docker creates a network between all containers managed by the same daemon so it’s possible to access other containers by their names.

say, we have 2 services - app and db:

$ docker-compose exec app sh
# ping db
PING db (172.18.XXX.XXX): 56 data bytes
64 bytes from 172.18.XXX.XXX: icmp_seq=0 ttl=64 time=0.359 ms

troubleshooting

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

solution

just install Docker app via brew cask.

it’s possible to install all the necessary docker tools (boot2docker, docker, docker-compose, etc.) manually but I didn’t manage to configure them all in reasonable time. so it’s better to install Docker app - it does all the heavy lifting for you.

$ brew cask install docker

don’t forget to run Docker app after installation (otherwise docker command will not be available in terminal).

lookup registry-1.docker.io on 192.168.65.1:53: no such host

when running docker run hello-world command host to pull hello-world image from is not found.

solution

host lookup fails when using some DNS servers (in particular when using DNS server of my Internet provider) - use Google DNS server 8.8.8.8 instead.