A test playground for Docker practice.
Born at a workshop by @codebar and @equalexperts.
- A GitHub account
- A Docker Hub account
- Ruby (version 2 and up) installed
- The Bundler gem installed
- Docker installed
- Create a new "automated build" repository in Docker Hub: This option can be found under the Create dropdown. Link it to your GitHub account when prompted.
- Enable automatic Docker image builds whenever you commit (optional): In your GitHub repo settings, add a webhook to Docker (browse the Add Service dropdown). If you don't enable this, you can still trigger Docker builds through the docker hub build settings page.
- Create and configure your Dockerfile: Add a
Dockerfile
to the root directory of your app configured to your custom build settings and push this to GitHub. In Docker Hub's Build Settings, set the location of your Dockerfile. You can clickTrigger
on the same screen to test your build, and see progress in the Build Details section.
-
Start the Docker Quickstart Terminal (install as part of Docker Toolbox)
-
Pull down and run the image:
docker run -p 8080:8080 krissy/dockertime
NB: the -p binds the ports from host to container, there are other ways to deal with EXPOSE and port binding - a decent article is here
-
Test your running app:
In a new Quickstart Terminal, find the IP of the docker host virtual machine:
docker-machine ip
Voila! Visit your app at
http://{your-docker-host-IP}:8080
-
Some other commands:
Display running containers:
docker ps
Display all running or stopped containers:
docker ps -a
Stop/start/restart:
docker [stop/start/restart] <container id or name>
Remove a stopped container instance:
docker rm <container id or name>
View logs:
docker logs <container id or name>
View detailed info:
docker inspect <container id or name>
View locally cached images:
docker images