0% found this document useful (0 votes)
8 views2 pages

Docker Commands

This document provides a guide on basic Docker commands for managing containers and images. It includes steps for running a container, building a Docker image from a Dockerfile, and cleaning up unused containers and images. Key commands such as 'docker run', 'docker build', and 'docker rm' are highlighted throughout the process.

Uploaded by

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

Docker Commands

This document provides a guide on basic Docker commands for managing containers and images. It includes steps for running a container, building a Docker image from a Dockerfile, and cleaning up unused containers and images. Key commands such as 'docker run', 'docker build', and 'docker rm' are highlighted throughout the process.

Uploaded by

Harry Dhillon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# Basic Commands

systemctl status docker


docker run hello-world

docker images
docker ps
docker ps -a

# Run a container
docker run --name web01 -d -p 9080:80 nginx
docker ps
docker inspect web01
curl [Link]

ip addr show
docker ps

# Go to browser enter IP:HostPort

# Building an Image
mkdir images
cd images/
vim Dockerfile

# Paste below content


FROM ubuntu:latest AS BUILD_IMAGE
RUN apt update && apt install wget unzip -y
RUN wget [Link]
RUN unzip 2128_tween_agency.zip && cd 2128_tween_agency && tar -czf [Link] * &&
mv [Link] /root/[Link]

FROM ubuntu:latest
LABEL "project"="Marketing"
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install apache2 git wget -y


COPY --from=BUILD_IMAGE /root/[Link] /var/www/html/
RUN cd /var/www/html/ && tar xzf [Link]
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
VOLUME /var/log/apache2
WORKDIR /var/www/html/
EXPOSE 80

# Build Image
docker build -t tesimg .
docker images

# Run container from our Image


docker run -P -d tesimg
docker ps

docker ps
ip addr show
docker ps

# Go to browser enter IP:HostPort

# CLEAN UP
docker ps
docker stop web01 heuristic_hugle
docker ps -a
docker rm heuristic_hugle web01 competent_gates elastic_ramanujan relaxed_sammet
clear
docker images
docker rmi a54ee9c44b3b 6130c26b5558 057d51c0049c 825d55fb6340 12766a6745ee
feb5d9fea6a5

You might also like