Skip to content

Instantly share code, notes, and snippets.

@stevesloka
Created February 23, 2016 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevesloka/54d63a2181faba316448 to your computer and use it in GitHub Desktop.
Save stevesloka/54d63a2181faba316448 to your computer and use it in GitHub Desktop.
# Docker 101 Workshop
PreReqs: You will need a docker-engine to run these examples! Please see the getting started guide on the main page for assistance.
## Run a container
1. Start your image:
```
docker run -d -p 80 tutum/hello-world
```
- It will print the new container ID (like d35bf1374e88). Get the allocated external port:
```
docker port d35bf1374e88 80
```
- It will print the allocated port (like 32768). Test your deployment:
```
curl http://localhost:32768/
```
```
Hello world!
```
## Build a container
1. Clone repo:
```
https://github.com/tutumcloud/hello-world.git
```
- To create the image upmce/hello-world, execute the following command on the docker-hello-world folder:
```
docker build -t upmce/hello-world .
```
- Check the image exists:
```
docker images
```
- Start your image:
```
docker run -d -p 80 upmce/hello-world
```
- It will print the new container ID (like d35bf1374e88). Get the allocated external port:
```
docker port d35bf1374e88 80
```
- It will print the allocated port (like 32768). Test your deployment:
```
curl http://localhost:32768/
```
```
Hello world!
```
### OPTIONAL:
1. Create repository in docker-hub WebUI
2. Tag the image
```
docker tag upmce/hello-world <yourDockerhubUsername>/hello-world
```
3. Push the image to docker hub:
```
docker push <yourDockerhubUsername>/hello-world
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment