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