Docker Commands Explained
docker run:
Used to create and start a container from a specified image. The syntax is: 'docker run [OPTIONS]
IMAGE [COMMAND] [ARGUMENTS]'.
docker exec:
Executes a command in a running container. The syntax is: 'docker exec -it CONTAINER_NAME
COMMAND'.
docker stop:
Stops a running container. The syntax is: 'docker stop CONTAINER_NAME'.
docker rm:
Removes a stopped container. The syntax is: 'docker rm CONTAINER_NAME'.
docker network create:
Creates a new network for containers. The syntax is: 'docker network create --driver
DRIVER_NAME NETWORK_NAME'.
docker network inspect:
Shows detailed information about a network. The syntax is: 'docker network inspect
NETWORK_NAME'.
docker network remove:
Removes a network. The syntax is: 'docker network rm NETWORK_NAME'.
docker service create:
Creates a new service for scaling with replicas. The syntax is: 'docker service create --name
SERVICE_NAME --replicas NUMBER --network NETWORK IMAGE'.
docker service ls:
Lists all services running. The syntax is: 'docker service ls'.
docker network ls:
Lists all networks available. The syntax is: 'docker network ls'.
docker service ps:
Shows the tasks (containers) running for a service. The syntax is: 'docker service ps
SERVICE_NAME'.
docker run --network host:
Run a container with the host's network stack. The syntax is: 'docker run --rm --network host -it
IMAGE COMMAND'.
docker network inspect ovn:
Inspect a specific network and show its configuration. The syntax is: 'docker network inspect
NETWORK_NAME'.
docker service create --name web --replicas 3 --network ovn nginx:
Create a service with 3 replicas using the nginx image and connect to the 'ovn' network.