Docker commands

List of useful docker commands:

A container is an instance of an image.

Install : https://docs.docker.com/engine/installation/linux/docker-ce/debian/

Check this docker hub repo: https://hub.docker.com/explore/

[code language=”bash”]
# Show available docker images
docker images

# Download image
docker pull debian

# Delete image
docker image rm <IMAGE_ID>

# Show containers
docker ps -a

# Create container from image
docker run -it –name="<CONTAINER_NAME>" <IMAGE_ID>
# You can forward ports with -p <HOST_PORT>:<CONTAINER_PORT>
# You can mount folders with -v /host/dir:/container/dest

# Delete container
docker rm <CONTAINER_ID>

# Run image interactively (creates container and removes it on exit)
docker run -it –rm=true <IMAGE_ID>

# Build docker image from Dockerfile, will be accessible by name <IMAGE_NAME>
docker build -t <IMAGE_NAME> .

# Stop container
docker stop <CONTAINER_ID>

# List volumes
docker volume ls

# Rename container
docker rename <CURRENT_CONTAINER_NAME> <NEW_CONTAINER_NAME>

# Add docker network
docker network create –subnet=172.18.0.0/16 <NETWORK_NAME>

# List docker networks
docker network list

# Delete docker network
docker network remove <NETWORK_ID>

# Start container with given IP in given network
docker run –net <NETWORK_NAME> –ip 172.18.0.2 -it –rm=true <IMAGE_NAME>

# Start container with given host name
docker run -it –rm=true -h <HOST_NAME> <IMAGE_NAME>
[/code]

This seems a nice UI for docker:
[code language=”bash”]
docker run -d -p 10086:10086 -v /var/run/docker.sock:/var/run/docker.sock tobegit3hub/seagull
[/code]
Then go to http://127.0.0.1:10086