Using Docker CLI
Luis Hernandez
Developer
lhernandez@nearsoft.com
Docker
Is a tool designed to make it easier to create, deploy, and run applications by using containers.
Portability
Build
Check images available locally:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
imageName tagName someId randomDate someMBs
Build an image from a dockerfile:
$ docker build -t myapp:1.0 .
Delete an image from the local image store:
$ docker rmi alpine:3.4
Ship
Docker Hub
Cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images
Ship
Login with your docker hub account:
$ docker login
Retag a local image with a new image name and tag
$ docker tag alpine:3.4 myrepo/myalpine:3.4
Push an image to the registry:
$ docker push myrepo/myalpine:3.4
Grab an image from remote registry:
$ docker pull alpine:3.4
Run
Run a container:
$ docker run
--rm
-it
--name containerName
-p 5000:80
-v ~/dev:/code
alpine:3.4
/bin/sh
$ docker stop containerName
$ docker kill containerName
Stop running a container:
Managing Containers
Run a container:
$ docker ps
$ docker ps -a
$ docker rm containerId
$ docker rm -f $(docker ps -aq)
Delete containers:
Diving inside Containers
Excute process inside the container and connect it to the terminal:
$ docker exec -it containerName commandName
$ docker logs containerName
Print logs:
Docker-Compose
Compose is a tool for defining and running multi-container Docker applications.
Docker-Compose CLI
$ docker-compose start
$ docker-compose stop
$ docker-compose pause
$ docker-compose unpause
$ docker-compose ps
$ docker-compose up
$ docker-compose down
Thanks
Using Docker CLI
By Luis Hernandez
Using Docker CLI
- 656