Docker Notes - fcrimins/fcrimins.github.io GitHub Wiki
See also: Web Hosting
- Bottom line: use --volume-from into a data-only container that does nothing other than expose a volume
- The dockerfile is generated by SBT at compile. There is an SBT plugin set up in the project, that enables the
sbt docker:publish
andsbt docker:publishLocal
commands. These compile and construct Docker image in one go. - The name of the sbt plugin is DockerPlugin and it’s a part of the sbt native packager. The configuration for it is all in build.sbt. You compile, construct your image with
sbt docker:publishLocal
, which stores the image in the docker repo on your local machine. If you have the latest image locally, then docker-compose will not pull from dockerhub, but rather use local repo image. - Is there a way to see which image is currently running?
- A:
docker-compose ps
should show the containers for the project and their status. - the last thing to look for is whether docker-compose recreates the hamstoo container from freshly compiled image — it should state "Recreating hamstoo_hamstoo_1" instead of "Starting hamstoo_hamstoo_1" on the first lines of program output for command
docker-compose up
(after a freshsbt docker:publishLocal
)
- A:
- Seems like generated.keystore is being generated in /opt/docker/conf, but that's in the container right? Not on my actual filesystem?
- Yes, it’s in the container, but also that is a linked volume, that syncs to [~/code/hamstoo/]conf/ on your local machine.
- what are the user rights set on your [~/code/hamstoo/]conf folder? 775
- try 777 so that docker could write the generated.keystore
- you can use
docker-compose exec hamstoo bash
to look inside. hamstoo is the name of the service you want to exec a command inside and bash obviously is that you want to run terminal inside the container- the same way you can run mongo shell
docker-compose exec mongo mongo
- the same way you can run mongo shell
- Error message: "236c6a10-c0d0-4522-ade8-7eb49b3ceda2/mongo STOPPED Reason: CannotCreateContainerError: API error (500): create ./mongo/configdb: "./mongo/configdb" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed ecscompose-hamstoo:2"
- This occurs because the
host-dir
, "./mongo/configdb", isn't an absolute path (doesn't start w/ a '/'), in which case it is assumed to be a volume name. See here for a suggested improvement to this error message. - "For example, you can specify either
/foo
orfoo
for ahost-dir
value. If you supply the/foo
value, the Docker Engine creates a bind-mount. If you supply thefoo
specification, the Docker Engine creates a named volume." -
This shows how to create a docker volume:
$ docker volume create --name=foo
- This explains how to create absolute paths.
- This occurs because the
- Error message: "STOPPED ExitCode: 255 <ip_addr>:9090->8080/tcp ecscompose-<image>:9"
- According to this it seems like 255 is caused by non-existent directories.
A more comprehensive Docker tutorial (2/3/17)
- A picture is worth a thousand words.
- "A running container is simply a standard OS process, plus file system dependencies and network connections."
- "It prevents the 'it works for me' excuses for when things break."
- "a Docker Compose script to mimic the
docker run
command, so we do not have to keep remembering the parameters."
- Includes a nice, seemingly comprehensive list of useful commands.
- To remove a docker image (per here):
$ docker rmi <sha12>
- "You can tag an image, and store multiple versions of that image with different GUIDs in a single named repository, access different tagged versions of an image with a special syntax like
username/image_name:tag
". For example:crimzie/hamstoo:latest
- Amazon EC2 Container Service says this: "Namespaces are optional, and they can be included in the repository name with a slash (for example,
namespace/repo
" - The Docker Terminology link above seems to confirm this interpretation: "So, this the confusing part: Suppose there's a Docker image called thoward/scooby_snacks. The official "repository name" is thoward/scooby_snacks, even though we would normally think of the repository as just being scooby_snacks (eg, in GitHub, or elsewhere). In fact, when the Docker documentation refers to a repository, it sometimes means the whole thing, username included, and sometimes only means the part after the username."
- Check out what's in
/var/lib/docker/repositories
JSON file which holds a mapping of repository names and tags, to the underlying image GUIDs in/var/lib/docker/graph/
.
- Amazon EC2 Container Service says this: "Namespaces are optional, and they can be included in the repository name with a slash (for example,
- $
sudo docker-compose up
- Error:
Unsupported config option for services service: 'web'
-
StackOverflow says I need to be using 1.6 (or later) version of docker-compose. I was running version 1.3 that I got from
apt-get
. - For a list of versions, see the Compose file format compatibility matrix
-
StackOverflow says I need to be using 1.6 (or later) version of docker-compose. I was running version 1.3 that I got from
- Error:
Couldn't connect to Docker daemon at http+docker://localunixsocker - is it running?
- Had to add
sudo
per here
- Had to add
- You can see the docker compose setup in docker-compose.yml in root folder. When used, it pulls two latest docker images from a repository (hamstoo backend and mongo db), runs them in a docker virtual machine and sets up their environment automatically.
- Don't use
sudo apt-get install docker docker-compose docker-engine
to install Docker. Instead follow the steps below.- Remove all existing Docker packages using the following commands:
apt list --installed | grep docker
andsudo apt-get remove <docker_package>
- Follow the 'Install using the repository' instructions here.
- "Before you install Docker for the first time on a new host machine, you need to set up the Docker repository."
- Continue on the same page through the 'Install Docker' section instructions, which will install
docker-engine
(version 1.12.6 at time of writing, 2/1/17) - Per step #3-4 on this page, go to here and run the following commands:
$ sudo -i
# curl -L https://github.com/docker/compose/releases/download/1.10.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- But then I was getting an error when running docker-compose from the PATH (when running with the full absolute path,
/usr/local/bin/docker-compose
--note the additional 'local'--it worked fine)- Here's the error:
bash: /usr/bin/docker-compose: No such file or directory
- Here was the fix:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
- Here was someone with a similar issue, which I commented on.
- Here's the error:
- And then I wasn't able to run
docker info
--but only as myself--as root it worked fine.
- Remove all existing Docker packages using the following commands: