반응형
신규 프로젝트가 대기중이다.
docker 나 k8s를 사용하는 프로젝트라고 이야기를 듣고, 공부를 시작하게됫다.
개념같은건 인터넷에 많으니까.. 난알고있고
테스트를 진행한다.
도커 설치
[ws@zserver03 ~]$ curl -fsSL <https://get.docker.com/> | sudo sh
[sudo] ws의 암호:
# Executing docker install script, commit: 4f282167c425347a931ccfd95cc91fab041d414f
+ sh -c 'yum install -y -q yum-utils'
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
+ sh -c 'yum-config-manager --add-repo <https://download.docker.com/linux/centos/docker-ce.repo>'
Loaded plugins: fastestmirror
adding repo from: <https://download.docker.com/linux/centos/docker-ce.repo>
grabbing file <https://download.docker.com/linux/centos/docker-ce.repo> to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* extras: mirror.kakao.com
* updates: mirror.kakao.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/10): docker-ce-stable/7/x86_64/filelists_db | 36 kB 00:00:00
(3/10): docker-ce-stable/7/x86_64/primary_db | 87 kB 00:00:00
(4/10): docker-ce-stable/7/x86_64/other_db | 127 kB 00:00:00
(5/10): extras/7/x86_64/other_db | 149 kB 00:00:00
(6/10): updates/7/x86_64/other_db | 1.2 MB 00:00:00
(7/10): extras/7/x86_64/filelists_db | 276 kB 00:00:00
(8/10): base/7/x86_64/other_db | 2.6 MB 00:00:01
(9/10): base/7/x86_64/filelists_db | 7.2 MB 00:00:01
(10/10): updates/7/x86_64/filelists_db | 9.6 MB 00:00:03
Metadata Cache Created
+ sh -c 'yum install -y -q docker-ce docker-ce-cli containerd.io docker-scan-plugin docker-compose-plugin docker-ce-rootless-extras'
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.6.9-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.6.9-3.1.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : <https://download.docker.com/linux/centos/gpg>
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit <https://docs.docker.com/go/rootless/> to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to <https://docs.docker.com/go/daemon-access/>
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
documentation for details: <https://docs.docker.com/go/attack-surface/>
================================================================================
[ws@zserver03 ~]$
</docker@docker.com>
Docker 버전확인 (실패)
[ws@zserver03 ~]$ docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[ws@zserver03 ~]$
Docker 버전확인 (정상)
[ws@zserver03 ~]$ sudo systemctl unmask docker.service
[ws@zserver03 ~]$ sudo systemctl unmask docker.socket
[ws@zserver03 ~]$ sudo systemctl start docker.service
[ws@zserver03 ~]$ docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied
[ws@zserver03 ~]$ sudo docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:02:38 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.9
GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[ws@zserver03 ~]$
Ubuntu run
[ws@zserver03 ~]$ sudo docker run ubuntu:18.04
Unable to find image 'ubuntu:18.04' locally
18.04: Pulling from library/ubuntu
a404e5416296: Pull complete
Digest: sha256:ca70a834041dd1bf16cc38dfcd24f0888ec4fa431e09f3344f354cf8d1724499
Status: Downloaded newer image for ubuntu:18.04
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ws@zserver03 ~]$ sudo docker run ubuntu:18.04
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ws@zserver03 ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce0b1a2beb5b ubuntu:18.04 "bash" 13 seconds ago Exited (0) 12 seconds ago romantic_mcclintock
cbf10637479f ubuntu:18.04 "bash" 42 seconds ago Exited (0) 39 seconds ago sleepy_banzai
[ws@zserver03 ~]$
Ubuntu bash run
[ws@zserver03 ~]$ sudo docker run --rm -it ubuntu:18.04 bash
root@4ab49d019a7c:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@4ab49d019a7c:/# exit
exit
[ws@zserver03 ~]$
Tomcat run
[ws@zserver03 ~]$ sudo docker run -d -p 8080:8080 --name tomcat-test tomcat
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat
e96e057aae67: Pull complete
014fa72e018d: Pull complete
06768b8afb03: Pull complete
3c12ca51ab80: Pull complete
55a6d794ff88: Pull complete
d948cb2b8ce0: Pull complete
0b75a9d4348a: Pull complete
Digest: sha256:5de987eeafd1182f31af7c97580d2a2bd06a1a2799623376c29c3b6e79e494cf
Status: Downloaded newer image for tomcat:latest
f6ca22598054bb08a807b99c61871ff50481c8505e971786c0dd3c4cfd97e1cc
[ws@zserver03 ~]$
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6ca22598054 tomcat "catalina.sh run" 3 minutes ago Up 3 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp tomcat-test
[ws@zserver03 ~]$
도커 설치
[ws@zserver03 ~]$ curl -fsSL <https://get.docker.com/> | sudo sh
[sudo] ws의 암호:
# Executing docker install script, commit: 4f282167c425347a931ccfd95cc91fab041d414f
+ sh -c 'yum install -y -q yum-utils'
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
+ sh -c 'yum-config-manager --add-repo <https://download.docker.com/linux/centos/docker-ce.repo>'
Loaded plugins: fastestmirror
adding repo from: <https://download.docker.com/linux/centos/docker-ce.repo>
grabbing file <https://download.docker.com/linux/centos/docker-ce.repo> to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* extras: mirror.kakao.com
* updates: mirror.kakao.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/10): docker-ce-stable/7/x86_64/filelists_db | 36 kB 00:00:00
(3/10): docker-ce-stable/7/x86_64/primary_db | 87 kB 00:00:00
(4/10): docker-ce-stable/7/x86_64/other_db | 127 kB 00:00:00
(5/10): extras/7/x86_64/other_db | 149 kB 00:00:00
(6/10): updates/7/x86_64/other_db | 1.2 MB 00:00:00
(7/10): extras/7/x86_64/filelists_db | 276 kB 00:00:00
(8/10): base/7/x86_64/other_db | 2.6 MB 00:00:01
(9/10): base/7/x86_64/filelists_db | 7.2 MB 00:00:01
(10/10): updates/7/x86_64/filelists_db | 9.6 MB 00:00:03
Metadata Cache Created
+ sh -c 'yum install -y -q docker-ce docker-ce-cli containerd.io docker-scan-plugin docker-compose-plugin docker-ce-rootless-extras'
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.6.9-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.6.9-3.1.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : <https://download.docker.com/linux/centos/gpg>
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit <https://docs.docker.com/go/rootless/> to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to <https://docs.docker.com/go/daemon-access/>
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
documentation for details: <https://docs.docker.com/go/attack-surface/>
================================================================================
[ws@zserver03 ~]$
</docker@docker.com>
Docker 버전확인 (실패)
[ws@zserver03 ~]$ docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[ws@zserver03 ~]$
Docker 버전확인 (정상)
[ws@zserver03 ~]$ sudo systemctl unmask docker.service
[ws@zserver03 ~]$ sudo systemctl unmask docker.socket
[ws@zserver03 ~]$ sudo systemctl start docker.service
[ws@zserver03 ~]$ docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied
[ws@zserver03 ~]$ sudo docker version
Client: Docker Engine - Community
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:04:24 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:02:38 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.9
GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[ws@zserver03 ~]$
Ubuntu run
[ws@zserver03 ~]$ sudo docker run ubuntu:18.04
Unable to find image 'ubuntu:18.04' locally
18.04: Pulling from library/ubuntu
a404e5416296: Pull complete
Digest: sha256:ca70a834041dd1bf16cc38dfcd24f0888ec4fa431e09f3344f354cf8d1724499
Status: Downloaded newer image for ubuntu:18.04
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ws@zserver03 ~]$ sudo docker run ubuntu:18.04
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ws@zserver03 ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce0b1a2beb5b ubuntu:18.04 "bash" 13 seconds ago Exited (0) 12 seconds ago romantic_mcclintock
cbf10637479f ubuntu:18.04 "bash" 42 seconds ago Exited (0) 39 seconds ago sleepy_banzai
[ws@zserver03 ~]$
Ubuntu bash run
[ws@zserver03 ~]$ sudo docker run --rm -it ubuntu:18.04 bash
root@4ab49d019a7c:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@4ab49d019a7c:/# exit
exit
[ws@zserver03 ~]$
Tomcat run
[ws@zserver03 ~]$ sudo docker run -d -p 8080:8080 --name tomcat-test tomcat
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat
e96e057aae67: Pull complete
014fa72e018d: Pull complete
06768b8afb03: Pull complete
3c12ca51ab80: Pull complete
55a6d794ff88: Pull complete
d948cb2b8ce0: Pull complete
0b75a9d4348a: Pull complete
Digest: sha256:5de987eeafd1182f31af7c97580d2a2bd06a1a2799623376c29c3b6e79e494cf
Status: Downloaded newer image for tomcat:latest
f6ca22598054bb08a807b99c61871ff50481c8505e971786c0dd3c4cfd97e1cc
[ws@zserver03 ~]$
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6ca22598054 tomcat "catalina.sh run" 3 minutes ago Up 3 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp tomcat-test
[ws@zserver03 ~]$
커뮤니티의 요청에 따라 wepapp 폴더의 내용이 webapp.dist폴더로 옮겨갔다고 합니다. 그래서 wepapp 폴더가 비워져 있었고, 브라우저에 보여줄(응답해줄) 파일이 존재하지 않은 이유로 404 error가 났던것입니다!
[ws@zserver03 ~]$ sudo docker exec -it tomcat-test /bin/bash
root@f6ca22598054:/usr/local/tomcat# mv webapps webapps2
root@f6ca22598054:/usr/local/tomcat# mv webapps.dist/ webapps
root@f6ca22598054:/usr/local/tomcat# exit
exit
[ws@zserver03 ~]$
컨테이너 정지
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6ca22598054 tomcat "catalina.sh run" 6 minutes ago Up 6 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp tomcat-test
[ws@zserver03 ~]$
[ws@zserver03 ~]$ sudo docker stop tomcat-test container
tomcat-test
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[ws@zserver03 ~]$
[ws@zserver03 ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6ca22598054 tomcat "catalina.sh run" 7 minutes ago Exited (143) About a minute ago tomcat-test
ce0b1a2beb5b ubuntu:18.04 "bash" 11 minutes ago Exited (0) 11 minutes ago romantic_mcclintock
cbf10637479f ubuntu:18.04 "bash" 11 minutes ago Exited (0) 11 minutes ago sleepy_banzai
[ws@zserver03 ~]$
컨테이너 삭제
[ws@zserver03 ~]$ sudo docker rm tomcat-test
tomcat-test
[ws@zserver03 ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce0b1a2beb5b ubuntu:18.04 "bash" 12 minutes ago Exited (0) 12 minutes ago romantic_mcclintock
cbf10637479f ubuntu:18.04 "bash" 13 minutes ago Exited (0) 13 minutes ago sleepy_banzai
[ws@zserver03 ~]$
mysql 설치
[ws@zserver03 ~]$ sudo docker run -d -p 3306:3306 \\
> -e MYSQL_ALLOW_EMPTY_PASSWORD=true \\
> mysql:5.7
Unable to find image 'mysql:5.7' locally
5.7: Pulling from library/mysql
9a0b9cd2dfe6: Pull complete
c637408ee7df: Pull complete
4c517093c276: Pull complete
301cc7d68c2a: Pull complete
17ca9bf9231a: Pull complete
9ae101e5c786: Pull complete
04baa409344e: Pull complete
f0b6015bf853: Pull complete
6005bb052ef8: Pull complete
99f303d57050: Pull complete
307a9a80c1df: Pull complete
Digest: sha256:0e3435e72c493aec752d8274379b1eac4d634f47a7781a7a92b8636fa1dc94c1
Status: Downloaded newer image for mysql:5.7
717729d1f3d1a9de065f9bb2a3ae9610f7a7afcb8696073869399bf42f17f56c
[ws@zserver03 ~]$
mysql 접속
[ws@zserver03 ~]$ mysql -h127.0.0.1 -uroot
Welcome to the MariaDB monitor. Commands end with ; or \\g.
Your MySQL connection id is 2
Server version: 5.7.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.
MySQL [(none)]>
[ws@zserver03 ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
717729d1f3d1 mysql:5.7 "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp recursing_haibt
[ws@zserver03 ~]$
[ws@zserver03 ~]$
[ws@zserver03 ~]$ sudo docker exec -it recursing_haibt mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 4
Server version: 5.7.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.
mysql>
Docker 이미지 확인
[ws@zserver03 ~]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest ab37a470285a 30 hours ago 474MB
mysql 5.7 eef0fab001e8 4 days ago 495MB
ubuntu 18.04 71eaf13299f4 2 weeks ago 63.1MB
여기까지 간단한 docker 명령어 사용법
반응형
'Study' 카테고리의 다른 글
KOSIS(국가통계포털) 통계자료 openAPI 사용 (0) | 2022.11.29 |
---|---|
kafka install (작성중) (0) | 2022.11.24 |
Apache JMeter 부하테스트 (2018) (0) | 2022.10.05 |
Columnstore multi combined install and addmodule (2017) (0) | 2022.09.19 |
Columnstore 1.0.x Binary Install Script (2017) (0) | 2022.09.19 |