Docker Basics
===
I looked at the "getting started" tutorial at and the "dockerfile reference" at . Both of these websites were helpful.
installation
---
Here's what I needed to install in order to create and test Docker images on Mac:
1. virtualBox
- Provides the virtual machine in which to run docker images.
- I had previously installed this, so I use the existing installation.
- It is possible to use other programs such as VMware, OpenStack, etc.
- You don't have to do much with this directly once it is installed. It works with `docker-machine` in the background.
1. docker
- Tools for creating and managing docker images.
- I installed this with `brew install docker`.
1. docker-machine
- Tools for managing docker-machines.
- I installed this with `brew install docker-machine`.
create and start machine
---
- `docker-machine create -d virtualbox testingDocker` **creates** a machine with virtualbox called `testingDocker`.
- You can check your docker-machines with `docker-machine ls`.
- `docker-machine start testingDocker` will **start** the machine.
- `docker-machine ip testingDocker` displays the IP of the machine.
- `docker-machine env testingDocker` displays some information about the running machine.
- `eval $(docker-machine env testingDocker)` to **setup your shell** for the running machine. Otherwise the `docker` tool won't work and you might get the error message:
`Cannot connect to the Docker daemon. Is the docker daemon running on this host?`
- `docker-machine stop testingDocker` **stops** the machine
hello world image
---
- check your docker images with `docker images`
- run hello-world with `docker run hello-world`
- If the image is not available locally, it will look for it at docker hub and download if it is found there.
- run a bash shell with `docker run -it ubuntu bin/bash`
port assignment with BMEG web portal
---
- Search docker hub at .
- download a docker image with `docker pull bmeg/web-portal`
- start the web app image with `docker run -p 3100:3000 -e ROOT_URL="http://localhost" bmeg/web-portal`
- `-p` maps image port to a host port
- `-e` sets environment variables to use in the running image
- `docker ps` shows information about currently running docker images
building a docker image
---
Docker images are built by creating a `Dockerfile`. The Dockerfile reference () describes the commands. Images can be built up from a base image using `FROM node:0.10.46`. The basic strategy I used was:
1. set up running environment with `RUN`, `EXPOSE`, and `ENV`
1. copy built web app into the image with `COPY`
1. install the app with `RUN`
1. setup default commands with `CMD`
1. **build** your image with `docker build --tag bmeg/web-portal .`
1. check that the image was build with `docker images`
1. test the image by running it
sharing your docker image
---
1. Login to .
1. Create a repository.
- **Be sure to include information about how to run your docker image!**
1. **push the image** to docker hub with `docker push bmeg/web-portal`
managing multi-container apps
---
Docker networking allows you to configure the container and host ports for services. However, it may be better to use the `docker-compose` tool for this configuration. I only know that such a tool exists and that it is configured via a `docker-compose.yml` configuration file. More information about `docker-compose` at .