버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

...

코드 블럭
vagrant@ubuntu-focal:~$ sudo apt update 
vagrant@ubuntu-focal:~$ docker images
vagrant@ubuntu-focal:~$ sudo -i
root@ubuntu-focal:~# apt install docker.io

...

코드 블럭
저장소 이름 (Repository Name) : default == docker hub 
이미지 이름 (Image Name) : nginx
이미지 태그 (Image Tag) : lastest (default)

(4) 이미지 가지고 오기

코드 블럭
$ docker pull nginx:latest
$ docker images
코드 블럭
# tag를 지정해주지 않으면 default로 latest 버전을 가져옵니다.
# tag를 지정할 경우 
# docker pull nginx:latest 
# 위의 명령어 대로 pull 가능
root@ubuntu-focal:~# docker pull nginx:latest
latest: Pulling from library/nginx
52d2b7f179e3: Pull complete
fd9f026c6310: Pull complete
055fa98b4363: Pull complete
96576293dd29: Pull complete
a7c4092be904: Pull complete
e3b6889c8954: Pull complete
da761d9a302b: Pull complete
Digest: sha256:104c7c5c54f2685f0f46f3be607ce60da7085da3eaa5ad22d3d9f01594295e9c
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
# 이미지 확인
root@ubuntu-focal:~# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    eea7b3dcba7e   2 weeks ago   187MB

...

코드 블럭
# docker run 이라는 명령어로 컨테이너를 실행시켜줍니다.
# docker run <옵션> <이미지 이름> <실행할 파일>
root@ubuntu-focal:~# docker run -it -d -p 80:80 --name=nginx nginx:latest
1303feec17205609e6303e72831084babeaebdfaec3bf9bf0f6f4e4b39082dd1
# 옵션 -i(interactive), -t(Pseudo-tty) -> Bash Shell에 입력 및 출력을 할 수 있습니다.
# 옵션 --name -> 컨테이너의 이름을 지정해 줍니다.
# 옵션 -d -> daemonized
# 옵션 -p -> 포트포워딩
  ex) 80:80 = [호스트의 포트] : [컨테이너의 포트]
root@ubuntu-focal:~# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                   NAMES
1303feec1720   nginx:latest   "/docker-entrypoint.…"   14 seconds ago   Up 14 seconds   0.0.0.0:8080->80/tcp, :::8080->80/tcp   nginx
root@ubuntu-focal:~# curl http://localhost:80
<!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>
정보

Docker docker create : 도커 이미지에서 새로운 컨테이너를 생성합니다. 그러나 즉시 실행되지는 않습니다

Docker docker start : 중지된 컨테이너를 시작합니다. docker create 명령을 사용하여 컨테이너를 만든 경우 이 명령으로 시작할 수 있습니다.

Docker docker run : create와 start의 조합으로 새 컨테이너를 생성하고 시작합니다. docker run 명령은 로컬 시스템에서 이미지를 찾지 못하는 경우 Docker Hub에서 이미지를 가져와서 컨테이너를 생성하고 실행합니다.

...

코드 블럭
root@ubuntu-focal:~# apt install nginx

#설치 확인
root@ubuntu-focal:~# nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
정보

socket() [::]:80 failed 에러가 나면, /etc/nginx/sites-enabled/default 에서

listen [::]:80 default_server; 삭제

(3) Nginx 확인

  • nginx를 패키지를 통하여 설치 하였기에 Default directory가 /etc/nginx 아래에 위치하게 됩니다.

  • 직접 compile한 경우에 경로는 /usr/local/nginx/conf 혹은 /use/local/etc/nginx 에 위치합니다.

...