chrisluiz16

supervisor

Jun 14th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1.  
  2.  
  3.  
  4. -------------------------------------- Docker file -----------------------------------------------------------
  5.  
  6.  
  7.  
  8. [ec2-user@ip-172-31-44-129 alpine]$ cat Dockerfile
  9. FROM httpd:alpine
  10.  
  11. ENV HOME_DIR /usr/local/apache2/
  12.  
  13. ENV USER chris
  14.  
  15. WORKDIR $HOME_DIR
  16.  
  17. RUN adduser -h $HOME_DIR -s /bin/sh -u 1005 -D chris
  18.  
  19. COPY ./public_html htdocs/
  20.  
  21. RUN mkdir .ssh/
  22.  
  23. COPY ./chrisops.pub .ssh/authorized_keys
  24.  
  25. RUN apk update && apk add supervisor openssh --no-cache
  26.  
  27. RUN ssh-keygen -A
  28.  
  29. RUN mv /usr/sbin/sshd /usr/bin/sshd
  30.  
  31. RUN cp /etc/ssh/ssh_host* .
  32.  
  33. RUN sed -i 's+#HostKey /etc/ssh/+HostKey /usr/local/apache2/+g' /etc/ssh/sshd_config
  34.  
  35. RUN chown -R $USER. $HOME_DIR
  36.  
  37. COPY ./supervisor.conf .
  38.  
  39. EXPOSE 22 80
  40.  
  41. USER $USER
  42.  
  43. ENTRYPOINT ["/usr/bin/supervisord"]
  44.  
  45. CMD ["-c","supervisor.conf"]
  46.  
  47.  
  48.  
  49.  
  50. ------------------------------------------------------ Supervidor.conf ----------------------------------------------------
  51.  
  52. [ec2-user@ip-172-31-44-129 alpine]$ cat supervisor.conf
  53. [supervisord]
  54. nodaemon=true
  55.  
  56.  
  57. [program:sshd]
  58. command=/usr/bin/sshd -D
  59.  
  60. [program:httpd]
  61. command=httpd-foreground
  62.  
  63.  
  64.  
  65. ------------------------------------------------- Docker image ------------------------------------------------
  66.  
  67. [ec2-user@ip-172-31-44-129 alpine]$ docker image build -t chrishttpd:1 .
  68. Sending build context to Docker daemon 2.371MB
  69. Step 1/19 : FROM httpd:alpine
  70.  
  71.  
  72. [ec2-user@ip-172-31-44-129 alpine]$ docker container run --name c1 -d -p 80:80 chrishttpd:1
  73. 1f8227969220d7cb901009a20b74e5803e67766010f996f7294df0ae94007281
  74.  
  75. [ec2-user@ip-172-31-44-129 alpine]$ docker network inspect bridge
  76. "Containers": {
  77. "1f8227969220d7cb901009a20b74e5803e67766010f996f7294df0ae94007281": {
  78. "Name": "c1",
  79. "EndpointID": "d0e803ef994a25dbaa5240052952bfd919bd409ce86dace21da38f8c2f94ba7c",
  80. "MacAddress": "02:42:ac:11:00:02",
  81. "IPv4Address": "172.17.0.2/16",
  82. "IPv6Address": ""
  83. }
  84. },
  85.  
  86.  
  87.  
  88.  
  89. ------------------------------------------Output --------------------------------------------
  90.  
  91. [ec2-user@ip-172-31-44-129 alpine]$ ssh -i chrisops [email protected]
  92. The authenticity of host '172.17.0.2 (172.17.0.2)' can't be established.
  93. ED25519 key fingerprint is SHA256:pKzvGv4OlEQPVWPod+tJVIZorKzqmEfdtjP7Xwb/gzc.
  94. This key is not known by any other names
  95. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
  96. Warning: Permanently added '172.17.0.2' (ED25519) to the list of known hosts.
  97. Welcome to Alpine!
  98.  
  99. The Alpine Wiki contains a large amount of how-to guides and general
  100. information about administrating Alpine systems.
  101. See <https://wiki.alpinelinux.org/>.
  102.  
  103. You can setup the system with the command: setup-alpine
  104.  
  105. You may change this message by editing /etc/motd.
  106.  
  107. 1f8227969220:/usr/local/apache2$
  108. 1f8227969220:/usr/local/apache2$
  109.  
  110.  
  111.  
  112.  
  113. ---------------------------------Every process running in chris user -----------------------------------
  114.  
  115. 1f8227969220:/usr/local/apache2$ ps aux
  116. PID USER TIME COMMAND
  117. 1 chris 0:00 {supervisord} /usr/bin/python3 /usr/bin/supervisord -c supervisor.conf
  118. 7 chris 0:00 httpd -DFOREGROUND
  119. 8 chris 0:00 sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups
  120. 10 chris 0:00 httpd -DFOREGROUND
  121. 11 chris 0:00 httpd -DFOREGROUND
  122. 12 chris 0:00 httpd -DFOREGROUND
  123. 94 chris 0:00 sshd: chris [priv]
  124. 96 chris 0:00 sshd: chris@pts/0
  125. 97 chris 0:00 -sh
  126. 98 chris 0:00 ps aux
  127.  
Advertisement
Add Comment
Please, Sign In to add comment