This repository contains links and commands for getting started with Docker.
Play With Docker is an instructional website affiliated with Docker. It provides an interactive and online terminal for getting started with Docker.
- Create an account at Docker Hub
- Do not use a password that has used elsewhere, it will be used on a public server during the demo.
- Create a new repository called
public-repo
at Docker Hub - Login to Play With Docker
- The terminal should appear within 10 seconds of logging in. If it doesn't, refresh the page until a prompt appears.
- In the PWD terminal, install
w3m
for terminal based web browsingapk update && apk add w3m
Copying and pasting works natively on MacOS using Command-C, ⌘ + c
and Command-V, ⌘ + v
. On Windows, use Control-Insert, CTRL + Insert
instead of Control-C, CTRL + c
and use Shift-Insert Shift + Insert
instead of Control-V, CTRL + v
.
docker version
docker run hello-world
docker pull grycap/cowsay
docker run --name cowsay grycap/cowsay "/usr/games/cowsay" "Hello World"
docker run -d -p 80:80 --name hello-world tutum/hello-world
curl localhost
w3m localhost
w3m
can be closed by hittingq
key
docker ps -a
docker images
docker stop hello-world
curl localhost
should now fail
docker start hello-world
docker rm -f hello-world
docker rm -f $(docker ps -a -q)
can be used to force remove all conainters
docker rmi tutum/hello-world:latest
docker rmi -f $(docker images -a -q)
can be used to force remove all images
git clone https://github.com/HammerMeetNail/pwd-demo.git
cd pwd-demo
cat Dockerfile
cat app.py
docker build -t add:v1.0.0 .
docker run --rm add:v1.0.0 1 2
docker run -it alpine:3.9 sh
- Leave the container by typing
exit
to end the shell session
- Leave the container by typing
docker run -it --entrypoint sh add:v1.0.0
- Browse around the container using common commands like
cd
,ls
,cat
- We can see the contents of our python app by running
cat /app/app.py
- Leave the container by typing
exit
to end the shell session
- Browse around the container using common commands like
docker run -it python:alpine sh
pip3 install requests
- The container has a full installation of
python3
andpip3
- Install python packages uses
pip3
, ex.pip3 install requests
- The container has a full installation of
- Start the interpreter using
python
- View the Zen of Python with
import this
- Import requests using
import requests
- View the Zen of Python with
- Quit the interpreter using
quit()
exit
docker login
- Make not of your full repository name, ex.
doconno2/public-repo
docker tag add:v1.0.0 {full repository name}:v1.0.0
- Replace
{full repository name}
with the full name of your repository - Example:
docker tag add:v1.0.0 doconno2/public-repo:v1.0.0
- Replace
docker push {full repository name}:v1.0.0
docker volume create temp
docker volume ls
docker run --rm -it -v temp:/temp alpine:3.9 sh -c 'echo "hello world" >> /temp/hello.txt'
docker rm -f $(docker ps -a -q)
docker ps -a
docker run --rm -it -v temp:/temp alpine:3.9 sh -c 'cat /temp/hello.txt'
docker volume rm temp
docker run --rm -it -v temp:/temp alpine:3.9 sh -c 'cat /temp/hello.txt'
docker system prune
docker-compose version
curl https://raw.githubusercontent.com/HammerMeetNail/pwd-demo/master/docker-compose.yml -O
cat docker-compose.yml
docker-compose up -d
curl localhost
w3m localhost
w3m
can be closed by hittingq
key
docker-compose logs cowsay-hello-world
docker-compose down
cd /tmp && curl https://raw.githubusercontent.com/HammerMeetNail/pwd-demo/master/docker-compose-k3s.yml -O
docker-compose -f docker-compose-k3s.yml up -d
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x kubectl && mv kubectl /usr/local/bin
kubectl --kubeconfig /tmp/kubeconfig.yaml get nodes
kubectl --kubeconfig /tmp/kubeconfig.yaml create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node
kubectl --kubeconfig /tmp/kubeconfig.yaml get po
kubectl --kubeconfig kubeconfig.yaml expose deployment hello-node --type=LoadBalancer --port=8080
kubectl --kubeconfig /tmp/kubeconfig.yaml get services
- Note the
External-IP
for thehello-node
LoadBalancer
- Note the
curl {external ip address}:8080
- Replace
{external ip address}
withExternal-IP
forhello-node
, ex.172.20.0.2
- Replace
Everything above should be runnable in Play-With-Docker, but if Play-With-Docker is unavailable Docker can be installed manually.