Docker Hub
Workshop
Created by
Andreas Grohmann
/
andreas.grohmann@gmx.de
/
twitter.com/grohmeo
# docker-hub * [motivation](#/2) * [overview](#/3) * [getting started](#/4)
## motivation * where to save images? * how to use existing images? * how to share images?
## overview ### what is Docker Hub * online service * registry for docker images and repositories * private/public space * couple of official image repositories * provides centralized resource for image discovery * easy to share own images
official Docker Hub repositories
https://hub.docker.com/explore/
getting started
check the wordpress repository
https://hub.docker.com/_/wordpress/
check the wordpress repository tags
https://hub.docker.com/r/library/wordpress/tags/
## getting started login ``` $ docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: YOUR-ACCOUNT Password: Login Succeeded ``` start mysql container from mysql image ``` $ docker run --name some-mysql -d -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:latest ``` check container ``` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ee495dcbce9c mysql:latest "docker-entrypoint..." 6 seconds ago Up 5 seconds 3306/tcp some-mysql ```
start wordpress container ``` $ docker run --name some-wordpress --link some-mysql:mysql -p 8080:80 -d wordpress:latest ``` check ```` $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f32f9e4f85e5 wordpress:latest "docker-entrypoint..." 8 seconds ago Up 7 seconds 0.0.0.0:8080->80/tcp some-wordpress ee495dcbce9c mysql:latest docker-entrypoint..." 8 minutes ago Up 8 minutes 3306/tcp some-mysql ```
check local wordpress server
http://localhost:8080
play around
http://localhost:8080
play around
http://localhost:8080
play around
http://localhost:8080
play around
http://localhost:8080
### stop and remove container stop ``` $ docker stop some-mysql $ docker stop some-wordpress ``` remove ``` $ docker rm some-mysql $ docker rm some-wordpress ```
### remove unused containers ( > Docker 1.13.x) show all containers ``` $ docker ps -a ``` prune containers ``` $ docker container prune ``` output ``` $ docker container prune WARNING! This will remove all stopped containers. Are you sure you want to continue? [y/N] y Deleted Containers: 36db3e614c82f24cf7774fb80aeced15d89f5f2daa9e2214a3f8416899e31116 303a198f1d038513aa9befcf438beb25a5edc543a98c53321171f7fdd1574930 cc281d90db872836b0cf82548336f167b4fc89969b83cd12309ad80f9d79f10d ``` check ``` $ docker ps -a ```
### remove unused images ( > Docker 1.13.x) ``` $ docker images ``` prune dangling images ``` $ docker system prune ``` prune images without containers ``` $ docker system prune -a ``` output ``` $ docker system prune -a WARNING! This will remove: - all stopped containers - all volumes not used by at least one container - all networks not used by at least one container - all images without at least one container associated to them Are you sure you want to continue? [y/N] y Deleted Volumes: 0f32fcf5576c207f548cd06c3a316d2fca306fdb54eaf349f1e326518aac7840 ``` ``` $ docker images ```
### remove unused images ( < Docker 1.13.x) ``` $ docker images ``` remove unused images ``` $ docker rmi $(docker images --filter "dangling=true" -q --no-trunc) ``` check ``` $ docker images ```
more trainings
training.play-with-docker.com
Questions?