Exec Form:
Dockerfile:
FROM ubuntu
RUN apt-get update && apt-get install -y nginx
EXPOSE 80
VOLUME My_Vol
ENTRYPOINT ["nginx", "-g", "daemon off;"] ==> executable form
Login to Container and check nginx process:
[root@ip-172-31-34-29 DockerDemo]# docker exec -it 6633147f038d sh
# top
top - 17:59:43 up 5 days, 16:01, 0 users, load average: 0.07, 0.04, 0.01
Tasks: 4 total, 1 running, 3 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 964.8 total, 175.9 free, 176.1 used, 612.7 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 641.1 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 55200 12036 10400 S 0.0 1.2 0:00.20 nginx
7 www-data 20 0 55524 3260 1324 S 0.0 0.3 0:00.00 nginx
13 root 20 0 2888 968 880 S 0.0 0.1 0:00.19 sh
18 root 20 0 7300 3476 2932 R 0.0 0.4 0:00.00 top
Shell Form:
Dockerfile:
[root@ip-172-31-34-29 DockerDemo]# cat Dockerfile
FROM ubuntu
RUN apt-get update && apt-get install -y nginx
EXPOSE 80
VOLUME My_Vol
#ENTRYPOINT ["nginx", "-g", "daemon off;"]
ENTRYPOINT nginx -g "daemon off;"
[root@ip-172-31-34-29 DockerDemo]# docker exec -it 13af7484a21d sh
# top
top - 18:02:06 up 5 days, 16:03, 0 users, load average: 0.00, 0.02, 0.00
Tasks: 5 total, 1 running, 4 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 964.8 total, 176.3 free, 175.3 used, 613.2 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 641.9 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 2888 956 864 S 0.0 0.1 0:00.19 sh
7 root 20 0 55200 12004 10364 S 0.0 1.2 0:00.00 nginx
8 www-data 20 0 55524 3376 1440 S 0.0 0.3 0:00.00 nginx
9 root 20 0 2888 988 896 S 0.0 0.1 0:00.19 sh
14 root 20 0 7304 3304 2760 R 0.0 0.3 0:00.00 top
[root@ip-172-31-34-29 DockerDemo]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13af7484a21d shellform "/bin/sh -c 'nginx -…" About a minute ago Up 59 seconds 80/tcp relaxed_borg
6633147f038d executeform "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp gallant_neumann
Exec form
This is the preferred form for CMD and ENTRYPOINT instructions.
The SHELL form runs the command as a child process (on a shell). The EXEC form runs the executable on the main proces
No comments:
Post a Comment