0% found this document useful (0 votes)
12 views5 pages

Docker_Commands

The document provides a comprehensive guide on installing Docker on Ubuntu, including setting up the repository, installing packages, and verifying the installation. It also lists basic Docker commands for managing images and containers, as well as demo programs like 'Hello-world' and 'Mine-Sweeper'. Additionally, it covers commands for Docker networks, volumes, and system management.

Uploaded by

balas995592
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Docker_Commands

The document provides a comprehensive guide on installing Docker on Ubuntu, including setting up the repository, installing packages, and verifying the installation. It also lists basic Docker commands for managing images and containers, as well as demo programs like 'Hello-world' and 'Mine-Sweeper'. Additionally, it covers commands for Docker networks, volumes, and system management.

Uploaded by

balas995592
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DOCKERS: INSTALLATION, BASIC COMMANDS, & INSTALLATION OF CLOUDSTACK

SIMULATOR
Link: https://docs.docker.com/engine/install/ubuntu/
[Steps for Installing Dockers]
1. Set up Docker's apt repository:
# Add Docker's official GPG key:
Step 1: sudo apt-get update
Step 2: sudo apt-get install ca-certificates curl
Step 3: sudo install -m 0755 -d /etc/apt/keyrings
Step 4: sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
Step 5: sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
Step 6:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc]
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 7: sudo apt-get update


2. Install the Docker packages
Step 8: sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-
compose-plugin
3. Verify that the installation is successful by running the hello-world image:
Step 9: sudo docker run hello-world
*************************************************************************************
[DEMO PROGRAMS]
Program-1: [Hello-world]
Step 1: sudo docker pull hello-world

Step 2: sudo docker run hello-world


Program-2: [Mine-Sweeper]
Step 1: sudo docker pull nadav42/minesweeper

Step 2: sudo docker run -it --rm -p 5000:5000 nadav42/minesweeper


Step 3: Open browser and type the following URL: http://localhost:5000

Docker Commands:
1. Docker Version Check: docker --version or docker version
2. List Docker Images: docker images
3. List Running Containers: docker ps
4. List All containers (Running and Stopped): docker ps -a
5. Pull the Busy Box image: docker pull busybox
6. Run a Busy Box image: docker run busybox
7. Run a Busy Box image with an interactive shell: docker run -it busybox
8. Run a Busy Box container and execute a command: docker run busybox echo “Hello from
busybox”
9. Stop a running container: docker stop <container id>
10. Remove a container: docker rm <container id>
11. Remove an image: docker rmi busybox
Common Commands to run inside the busy box:
1. Run busy box with an interactive shell: docker run -it busybox sh
2. Check the version of busybox: busybox
3. View the File Systems: ls
4. Display the current directory: pwd
5. Create a new directory: mkdir /mydir
6. Change to different directory: cd /mydir
7. Create a new file: echo “Hello, Busy box” > hello.txt
8. View the content of the file: cat hello.txt
9. Delete a file: rm hello.txt
10. Check IP Address: ifconfig
11. Ping a host: ping google.com
12. List Running Process: ps
13. Kill a process: kill <pid>
14. Display date and time: date
15. Disk usage: df -h
16. Check memory usage: free
17. Exit the busy box: exit
*************************************************************************************
FEW MORE BASIC COMMANDS
Docker Installation & Version Check
docker --version # Show Docker version
docker info # Display system-wide information

Docker Images
docker pull <image_name> # Download image from Docker Hub
docker images # List all downloaded images
docker rmi <image_name> # Remove an image
docker tag <image_id> <new_tag> # Tag image with a new name

Docker Containers
docker run <image_name> # Run container from image
docker run -it <image_name> /bin/bash # Run container in interactive mode
docker run -d <image_name> # Run container in detached mode
docker run --name mycontainer <image_name> # Run container with a custom name
docker ps # List running containers
docker ps -a # List all containers
docker start <container_id> # Start a stopped container
docker stop <container_id> # Stop a running container
docker restart <container_id> # Restart a container
docker rm <container_id> # Remove a container

Docker Logs & Inspection


docker logs <container_id> # View container logs
docker inspect <container_id> # Inspect container details
docker top <container_id> # View running processes inside container
Docker Exec & Attach
docker exec -it <container_id> /bin/bash # Run bash in a running container
docker attach <container_id> # Attach to a running container

Docker Networks
docker network ls # List all networks
docker network inspect <network_name> # Inspect a specific network
docker network create <network_name> # Create a new Docker network
docker network rm <network_name> # Remove a Docker network

Docker Volumes
docker volume ls # List all volumes
docker volume create <volume_name> # Create a volume
docker volume inspect <volume_name> # Inspect a volume
docker volume rm <volume_name> # Remove a volume

Docker System Management


docker system df # Show Docker disk usage
docker system prune # Remove unused containers, networks, images,
volumes

You might also like