Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Dockerhub Team Reference
Daniel Götz 30.04.2016
Just stick to the website: https://docs.docker.com/engine/installation/mac/ (underneath is the documentation for windows and linux)
Pulling our image from Dockerhub
After installing docker you are able to pull images from Dockerhub. The address of our repo is the following: https://hub.docker.com/r/amosproj5/amosbuildimage/
You can pull differently tagged images by using (and obviously replacing the tag with a real tag, for example v1 or latest, which is default in docker):
$ docker pull amosproj5/amosbuildimage:tag
Default tag for our repo is 'v1' right now. Additionally, there will be the "release" Tag.
Running in foreground
You can run docker instances in the foreground, which allows you for example to directly watch output or give input via command line.
$ docker run -t -i -P --rm ubuntu /bin/bash
- docker run runs a container
- ubuntu is the image to run
- -t assigns a pseudo-tty or terminal inside the new container (basically you have a terminal right at the start)
- -i allows you to make an interactive connection by grabbing the STDIN of the container
- -P used for port mapping
- --rm deletes the container right after the process exits
- /bin/bash the command to be executed when the container starts up. Opens a shell in this case.
Running in background with the docker daemon
It's also possible to run docker instances in the background, which would be more useful if you use multiple containers at once or want to attach at a later time.
$ docker run -d --name asdf -v /src/webapp:/opt/webapp ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
- -d runs the container in the background (daemonized)
- --name sets the container instance's name (in this case asdf)
- -v src:dest mounts the src directory/file from the host into dest in the container (useful for binaries or code sources)
Commands for working with running containers
- docker images shows all images on your host
- docker ps shows alle running containers with additional info
- docker logs shows stdoutput of a container
- docker port shows port mapping
- docker attach attach to container ; detach with CTRL-p CTRL-q
- docker stop stops the running container
- docker start starts a stopped container again
- docker rm deletes (stopped) container
- docker inspect network bridge shows network info (ip-addresses!) for a container
Networking with Docker Containers (in our case only on the same host)
If your docker container instances reside on the same host, you can use the standard bridge network.
Create the network
Use $ docker network create --driver bridge name to create a new network named name. It uses the standard bridge driver. You can view additional information with
$ docker network inspect <name>
and get an overview of the active networks by using
$ docker network ls
Connect a container instance to the network
To connect a container instance to your newly created network, just use the run parameter --net
$ docker run --net=<NETWORK> --name=name_container
afterwards you can run network inspect to get the ip-addresses of all connected containers.