Docker Commands Explained
This document contains a list of Docker commands along with detailed explanations.
Command: docker run -d --name container3 --network mynetwork alpine
Explanation: Runs a new container 'container3' in detached mode with the 'alpine' image, connecting to the 'mynetwork'
network.
Command: docker exec -it container4 /bin/sh
Explanation: Executes a shell in 'container4' interactively.
Command: docker network create --driver bridge mynetwork
Explanation: Creates a new Docker network 'mynetwork' using the 'bridge' driver.
Command: docker network remove mynetwork
Explanation: Removes the Docker network 'mynetwork'.
Command: docker network inspect mynetwork
Explanation: Displays detailed information about the 'mynetwork' network.
Command: docker stop container3 container4
Explanation: Stops the running containers 'container3' and 'container4'.
Command: docker rm container3 container4
Explanation: Removes the stopped containers 'container3' and 'container4'.
Command: docker network inspect mynetwork
Explanation: Shows information about the 'mynetwork' network.
Command: docker run -d --name container3 --network mynetwork alpine
Explanation: Starts a new container named 'container3' with the 'alpine' image, in detached mode, and connected to
'mynetwork'.
Command: docker service create --name web --replicas 3 --network ovn nginx
Explanation: Creates a Docker service named 'web' with 3 replicas, connected to the 'ovn' network, using the 'nginx'
image.
Command: docker network create --driver overlay ovn
Explanation: Creates an overlay network named 'ovn', used for Docker Swarm services.
Command: docker ps
Explanation: Lists all the running containers.
Command: docker network ls
Explanation: Lists all Docker networks.
Command: docker ps -a
Explanation: Lists all containers, including stopped ones.
Command: docker logs container_name
Explanation: Shows logs of the specified container.
Command: docker-compose up
Explanation: Starts up all the services defined in the 'docker-compose.yml' file.
Command: docker-compose down
Explanation: Stops and removes all the containers, networks, and volumes defined in the 'docker-compose.yml' file.