Tales From The Keyboard: Getting To Know Docker

How Is Docker Running In Your Computer?

ERROR: for <service name> Cannot start service <service name>: b'Mounts denied: The path /path/to/mount is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.'
I usually mount my $HOME/projects folder to save some time.
ERROR: bootstrap checks failed max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
sysctl: unknown oid 'vm.max_map_count'
You can modify other VM settings in this window.
$ screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

Dabbling in docker-compose

  • Single-value: (e.g. image, command or mem_limit) The value from the .override file will be used.
  • Multi-value: These fields are treated as arrays or maps and depending on the type of field docker-compose will act differently:
  • ports, expose, external_links, dns, dns_search and tmpfs are concatenated. Meaning we can never completly override the value set on the first file, we can only add more values to the array or map. I recommend being conservative with the value used on the first file.
  • environment and labels are merged together. Meaning, we can add more values to the array or map and we can override previously set values. The trick here is that the values used in this array or map are in the form of UNIQUE_STRING:VALUE. docker-compose will use the left side of the string as uniqueness and will override values based on that.
  • volumes and devices are also merged together. Meaning, we can add more values to the array and we can override previously set values. The difference here is that docker-compose will use the right side of the string as uniqueness. docker-compose will see every value as VALUE:UNIQUE_STRING. This makes sense because the right side of the value is unique for the container we are creating.
$ docker-compose -f docker-compose.local-dev.yml -f docker-compose.local-dev.override.yml -f docker-compose.local-dev.shenanigans.yml
$ docker-compose config

Bringing up and down the house

  • Prepended to every service name. If one of the service’s name is django, the container created will be named PROJECT_NAME_django_1 unless container_name is defined in the service definition.
  • When defining volumes in reality the volume’s name is prepended with PROJECT_NAME. We can verify this by using docker volume ls.
  • PROJECT_NAME is also prepended to any network defined. We can also verify this by using docker network ls.
  1. Pull necessary images: docker-compose pull
  2. Build necessary images: docker-compose build
  3. Create necessary networks and volumes:$ docker-compose up --no-build --no-start
  4. Run services: docker-compose up
$ docker-compose up --force-recreate
$ docker-compose down --rmi=all -v --remove-orphans

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store