Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views3 pages

Dockers Basic Program PDF

The document provides a series of programs and commands for working with Docker, including installation, image setup, and container management. It covers commands for checking Docker status, creating images, exposing ports, managing containers, and adding external containers. Each program includes specific commands to execute for various Docker functionalities.

Uploaded by

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

Dockers Basic Program PDF

The document provides a series of programs and commands for working with Docker, including installation, image setup, and container management. It covers commands for checking Docker status, creating images, exposing ports, managing containers, and adding external containers. Each program includes specific commands to execute for various Docker functionalities.

Uploaded by

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

Program1: Docker Installation and Image setup.

docker –version
2. To check the working of docker
docker info
3. To set up an image (docker pull image name)
docker pull hello-world
4. To run the image (docker run image name)
docker pull hello-world
5. To see the image, you have created
docker images

Program2: Creating Images from Containers

Commands
docker container run -d --name mynginx nginx

Program3:
Exposing Container Ports to the Host
Commands
 docker run -d -p <host-port>:<container-port> <image-name>
docker ps

Program 4:
mkdir my-docker-project
cd my-docker-project

# Use an official Ubuntu base image


FROM ubuntu:latest
# Install Nginx
RUN apt update && apt install -y nginx

# Expose port 80
EXPOSE 80
# Start Nginx when the container starts
CMD ["nginx", "-g", "daemon off;"]

docker build -t my-custom-image .( wait for few seconds

docker run -d -p 8080:80 --name my-nginx-container my-custom-image


docker ps

Program 5:
Managing Containers

Commands
Lists running containers
docker ps

Lists all containers (including stopped ones)

docker ps -a

(running a container )
docker run -d --name my-container nginx
Stops the container

docker stop my-container


Starts the container again
docker start my-container

Program 6: Adding external containers to the containers

Commands:
docker pull alpine
docker run -it alpine sh
docker run -it alpine (run the command and exit)
docker run -d -p 8080:80 alpine
docker run -d -p 8080:80 alpine

You might also like