Commands

List all the images

docker images

Download image

https://hub.docker.com/

# docker pull [image]
docker pull mysql

Delete image

# docker image rm [image]
# docker image rm [image]:[tag]
docker image rm mysql
docker image rm mysql:latest
docker image rm mysql:16

Create a container with the image

With random container name

It will generate an ID to the container.

Id generated:

With custom container name

Id generated:

Start a container

Using the ID of the container

Using the custom name of the container

Using environment variables

For example, to create a mongodb container with specific user and password, to then use an app to connect to it, we use the env variable described in mongodb hub:

https://hub.docker.com/_/mongo

Each image has different ways to configure

Status of containers running

Stop a container

List of containers started and off

List all the containers in system.

Delete a container

Using name

Expose a container in a host port

Custom port

Random port

Check logs of container

Or to stay watching those logs:

Download the image, create and start the container

With logs view, random data

Without logs view, detach mode and random data

It generates our container ID:

Without logs view and custom data

Interact with networks

List networks

Create a network

Delete a network

Last updated