-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_hands_on_command
68 lines (51 loc) · 1.38 KB
/
docker_hands_on_command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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 http://172.17.0.2:80
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 https://www.tooplate.com/zip-templates/2128_tween_agency.zip
RUN unzip 2128_tween_agency.zip && cd 2128_tween_agency && tar -czf tween.tgz * && mv tween.tgz /root/tween.tgz
FROM ubuntu:latest
LABEL "project"="Marketing"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install apache2 git wget -y
COPY --from=BUILD_IMAGE /root/tween.tgz /var/www/html/
RUN cd /var/www/html/ && tar xzf tween.tgz
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