오늘은 복습/실습/자습 위주로 진행 되었다.
GIT
GIT은 어제 했던 내용 그대로라 무난하게 성공했다.
결과
Docker
ubuntu
nginx 버전 확인
root@86e66c731e49:/# nginx -V
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-KTLRnK/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module
git 버전 확인
root@86e66c731e49:/# git --version
git version 2.25.1
curl 버전 확인
root@86e66c731e49:/# curl -V
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
centos
nginx 설치
제일 애먹었던 centos에 nginx 설치...centos8로 깔았다가 먼 길 돌아왔다. 왠만하면 centos7을 사용하자.
설치 참고
패키지 관리자를 통해 NGINX 최신 버전(Mainline/Stable) 설치하기
아무런 조치 없이 리눅스의 패키지 관리자를 통해서 웹 서버인 NGINX를 설치하게 되면 자신이 원하는 버전을 설치하지 못할뿐더러, 현재 패키지 관리자에선 구 버전이 기본 설정되어 있습니다.
goodlife-coding.tistory.com
container에서 systemctl 명령 사용시 Failed to get D-Bus connection Operation not permitted 에러 해결하기
wiki.terzeron.com
nginx 실행(sudo 명령어 제외하고 진행)
Failed to start nginx.service: Unit not found
I installed the latest version of nginx and configured some directories: ./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-
stackoverflow.com
nginx 버전 확인
[root@a6c7276c6436 yum.repos.d]# nginx -v
nginx version: nginx/1.21.6
git 설치 확인
[root@a6c7276c6436 /]# git --version
git version 2.27.0
curl 설치 확인
[root@a6c7276c6436 /]# curl -V
curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 nghttp2/1.33.0
Release-Date: 2018-09-05
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy
practice-ubuntu
참고
Docker - 도커로 nginx 웹서버 구축하기
도커 입문 수업을 듣고 중요한 내용을 정리했습니다. 개인 공부 후 자료를 남기기 위한 목적이므로 내용 상에 오류가 있을 수 있습니다. 도커로 nginx 웹서버 구축하기 docker를 통해 ubuntu:20.04에 ngi
unpasoadelante.tistory.com
nginx 실행
root@068effd42597:/# service nginx start
* Starting nginx nginx
curl : 우분투 도커 컨테이너 내에서 nginx 내부 서버 동작 확인
root@068effd42597:/# curl -X GET http://127.0.0.1:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
이미지로 commit
PS C:\Users\user> docker commit 068 nginx-ubuntu
sha256:fa7e75e8cd6c66093321f553c105369cc727de7a1eeb8ec7f73c080412efc627
nginx1 생성
PS C:\Users\user> docker run -dit --name nginx1 -p 8080:80 nginx-ubuntu
d885ddd0086dbf04f35eae57513cdb3437dc44e3c548ea72c40576b1daa26acb
PS C:\Users\user> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d885ddd0086d nginx-ubuntu "bash" 24 seconds ago Up 23 seconds 0.0.0.0:8080->80/tcp nginx1
068effd42597 ubuntu:20.04 "bash" 36 minutes ago Up 36 minutes practice-ubuntu
nginx1 실행
PS C:\Users\user> docker exec -it nginx1 service nginx start
* Starting nginx nginx [ OK ]
PS C:\Users\user> docker exec -it nginx1 service nginx status
* nginx is running
결과
practice-centos
nginx 실행
[root@41f5a66d21b5 yum.repos.d]# systemctl start nginx
[root@41f5a66d21b5 yum.repos.d]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-02-09 08:15:40 UTC; 19s ago
Docs: http://nginx.org/en/docs/
Process: 300 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 301 (nginx)
Tasks: 9 (limit: 80833)
Memory: 8.4M
CGroup: /system.slice/nginx.service
├─301 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
├─302 nginx: worker process
├─303 nginx: worker process
├─304 nginx: worker process
├─305 nginx: worker process
├─306 nginx: worker process
├─307 nginx: worker process
├─308 nginx: worker process
└─309 nginx: worker process
Feb 09 08:15:40 41f5a66d21b5 systemd[1]: Starting nginx - high performance web server...
Feb 09 08:15:40 41f5a66d21b5 systemd[1]: Started nginx - high performance web server.
curl : centos 도커 컨테이너 내에서 nginx 내부 서버 동작 확인
[root@41f5a66d21b5 yum.repos.d]# curl http://localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
이미지로 commit
PS C:\Users\user> docker commit 41f nginx-centos
sha256:124486b733afa881e38ea11d54415cfc2e2c2096c74a17aa22a43ab29a0910b0
nginx2 생성
PS C:\Users\user> docker run -dit --name nginx2 -p 8081:80 nginx-centos
abe80fd59ce5901d7aa8c012afc35f408d5b2f5eaff65ac8727792074f3894d7
PS C:\Users\user> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abe80fd59ce5 nginx-centos "/usr/sbin/init" 15 seconds ago Up 14 seconds 0.0.0.0:8081->80/tcp nginx2
d885ddd0086d nginx-ubuntu "bash" 4 minutes ago Up 4 minutes 0.0.0.0:8080->80/tcp nginx1
41f5a66d21b5 centos "/usr/sbin/init" 20 minutes ago Up 20 minutes practice-centos
068effd42597 ubuntu:20.04 "bash" 41 minutes ago Up 41 minutes practice-ubuntu
nginx2 실행하려했는데 또! Host is Down 에러가 떴다.
PS C:\Users\user> docker exec -it nginx2 systemctl start nginx
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
그래서 또 다시 위에 했던 방식으로 만들어줬다...(물론 그전에 기존 8081 포트 띄웠던 컨테이너는 삭제해줬다.)
PS C:\Users\user> docker run -d --privileged -p 8081:80 -v /sys/fs/cgroup:/sys/fs/cgroup:ro nginx-centos /usr/sbin/init
b2f85b831da13d7df91e237aa9c37b82add8f4ce67aedc47fe1cb6df070d5a51
새로 띄운 컨테이너의 이름 nginx2로 변경
PS C:\Users\user> docker rename elated_nightingale nginx2
PS C:\Users\user> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b2f85b831da1 nginx-centos "/usr/sbin/init" 52 seconds ago Up 48 seconds 0.0.0.0:8081->80/tcp nginx2
d885ddd0086d nginx-ubuntu "bash" 26 minutes ago Up 26 minutes 0.0.0.0:8080->80/tcp nginx1
41f5a66d21b5 centos "/usr/sbin/init" 42 minutes ago Up 42 minutes practice-centos
068effd42597 ubuntu:20.04 "bash" About an hour ago Up About an hour practice-ubuntu
nignx 실행
PS C:\Users\user> docker exec -it nginx2 systemctl start nginx
PS C:\Users\user> docker exec -it nginx2 systemctl status nginx
Failed to dump process list for 'nginx.service', ignoring: Input/output error
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-02-09 08:49:01 UTC; 19s ago
Docs: http://nginx.org/en/docs/
Process: 93 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 94 (nginx)
Tasks: 18 (limit: 80833)
Memory: 16.9M
CGroup: /system.slice/nginx.service
Feb 09 08:49:01 b2f85b831da1 systemd[1]: Starting nginx - high performance web server...
Feb 09 08:49:01 b2f85b831da1 systemd[1]: Started nginx - high performance web server.
결과
느낀 점
centos 정말 낯설다...
에러메세지 때문에 구글링하고 똑같은 명령어 치는 작업을 반복하니 덕분에 도커에 조금 익숙해진 것 같다.
어쨌든 시간 내에 해내서 기쁘다!
'공부 > [TIL] Digital Twin Bootcamp' 카테고리의 다른 글
TIL_220211_인공지능 (0) | 2022.02.11 |
---|---|
TIL_220210_IIoT CPS / 클라우드 컴퓨팅 (0) | 2022.02.10 |
TIL_220208_DevOps / Docker (0) | 2022.02.08 |
TIL_220207_DevOps/Git/Github (0) | 2022.02.07 |
TIL_220204_HMI (0) | 2022.02.04 |