SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
Docker Practice
한국폴리텍대학 스마트금융과
Precondition
Ubuntu 18.04 LTS or Above
Docker Install (Latest version)
apt-get install libltdl-dev
Docker Engine: Version 17.06.2-ce or higher
wget
https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/do
cker-ce_17.06.2~ce-0~ubuntu_amd64.deb
dpkg -i docker-ce_17.06.2~ce-0~ubuntu_amd64.deb
docker —version
curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-
compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker–compose –versionhttps://phoenixnap.com/kb/install-docker-compose-ubuntu
Docker?
별도 Process
적층형 이미지
출처: https://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal
https://2eof2j3oc7is20vt9q3g7tlo5xe-wpengine.netdna-ssl.com/wp-content/uploads/2014/08/ibm-various-virtualization.jpg
기본 명령어
sudo docker version
docker images
root@hwy:~# docker version
Client: Docker Engine - Community
Version: 19.03.2
API version: 1.40
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:29:11 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.2
API version: 1.40 (minimum version 1.12)
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:27:45 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683
root@hwy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test 0.1 70e817b514c4 3 weeks ago 876MB
test_test 0.1 60f9924c8777 3 weeks ago 1.22MB
busybox latest b534869c81f0 4 weeks ago 1.22MB
ubuntu 16.04 56bab49eef2e 5 weeks ago 123MB
mysql 5.7 1e4405fe1ea9 6 weeks ago 437MB
nginx latest 231d40e811cd 6 weeks ago 126MB
docker pull
docker search
root@hwy:~# docker pull ubuntu:18.04
18.04: Pulling from library/ubuntu
2746a4a261c9: Pull complete
4c1d20cdee96: Pull complete
0d3160e1d0de: Pull complete
c8e37668deea: Pull complete
Digest: sha256:250cc6f3f3ffc5cdaa9d8f4946ac79821aafb4d3afc93928f0de9336eba21aa4
Status: Downloaded newer image for ubuntu:18.04
docker.io/library/ubuntu:18.04
root@hwy:~# docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 10328 [OK]
dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 381 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 239 [OK]
consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 203 [OK]
ubuntu-upstart Upstart is an event-based replacement for th… 102 [OK]
ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 98 [OK]
neurodebian NeuroDebian provides neuroscience research s… 63 [OK]
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK]
ubuntu-debootstrap debootstrap --variant=minbase --components=m… 41 [OK]
nuagebec/ubuntu Simple always updated Ubuntu docker images w… 24 [OK]
i386/ubuntu Ubuntu is a Debian-based Linux operating sys… 18
1and1internet/ubuntu-16-apache-php-5.6 ubuntu-16-apache-php-5.6 14 [OK]
1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 13 [OK]
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10 ubuntu-16-nginx-php-phpmyadmin-mariadb-10 11 [OK]
…
ubuntu
root@hwy:~# docker run -i -t ubuntu:latest /bin/bash
(i : interactive(사용자 입출력), t: tty)
exit 입력 -> container 종료
root@hwy:~# docker run -i -t ubuntu:latest /bin/bash
root@c7c709ecddb6:/#
root@c7c709ecddb6:/# uname -a
Linux c7c709ecddb6 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@c7c709ecddb6:/# whoami
root
root@c7c709ecddb6:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@c7c709ecddb6:/#
root@c7c709ecddb6:/#
root@c7c709ecddb6:/# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 04:53 pts/0 00:00:00 /bin/bash
root 13 1 0 04:56 pts/0 00:00:00 ps -ef
root@c7c709ecddb6:/#
docker ps
docker start
 without shell
docker attach
root@hwy:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7c709ecddb6 ubuntu:latest "/bin/bash" 5 minutes ago Exited (127) 5 seconds ago unruffled_leakey
root@hwy:~# docker start unruffled_leakey
unruffled_leakey
root@hwy:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c7c709ecddb6 ubuntu:latest "/bin/bash" 7 minutes ago Up 13 seconds unruffled_leakey
※ docker run = 컨테이너 생성 + docker start + docker attach
root@hwy:~# docker attach unruffled_leakey
root@c7c709ecddb6:/#
attach 된 상태에서 exit하면 container 가 종료됨
container를 종료하지 않고 쉘에서 빠져나오려면
Ctrl + P,Q
root@c7c709ecddb6:/# read escape sequence
root@hwy:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED
c7c709ecddb6 ubuntu:latest "/bin/bash" 17 minutes ago
docker stop
docker rm [이름]
 컨테이너 삭제
docker rmi [리포지토리 이름]
 이미지 삭제
root@hwy:~# docker stop unruffled_leakey
unruffled_leakey
root@hwy:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@hwy:~#
root@hwy:~# docker run -d --name mynginx nginx
03a6c48083eb256d65f21f056a6080e288f2ac071854fb24c1a95c9b82bdb6a4
docker run -d --name mynginx -p 8000:80 nginx
root@hwy:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03a6c48083eb nginx "nginx -g 'daemon of…" 8 seconds ago Up 6 seconds 80/tcp mynginx
-d
detached 옵션으로
백그라운드로 실행
-p 포트맵핑
서버 포트 : 컨테이너 포트
docker exec root@hwy:~# docker run -i -t --name hello ubuntu /bin/bash
root@hwy:~# docker exec hello echo 1
root@hwy:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a3d2aa1a1e3 ubuntu "/bin/bash" 59 seconds ago Up 57 seconds hello
2d35fa16ce28 nginx "nginx -g 'daemon of…" 16 minutes ago Up 16 minutes 0.0.0.0:8000->80/tcp mynginx
root@hwy:~# docker exec hello touch /hello.txt
root@hwy:~# docker attach hello
root@6a3d2aa1a1e3:/# ls /
bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
docker commit
root@hwy:~# docker commit 6a3d2aa1a1e3 test_commit:0.1
sha256:efc60c45ec5e59646e1a98e583ea930e7b37b1e0c742b20b2d1e34e46bec71b5
root@hwy:~# docker images
root@hwy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test_commit 0.1 efc60c45ec5e 6 seconds ago 64.2MB
root@hwy:~# docker run -it test_commit:0.1
root@d6aee93a68f0:/# ls /
a.txt bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
docker login
docker logout
docker tag
docker push
root@hwy:~# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: wyhwang
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
root@hwy:~# docker tag test_commit:0.1 wyhwang/test_commit:latest
root@hwy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wyhwang/test_commit latest efc60c45ec5e 37 minutes ago 64.2MB
test_commit 0.1 efc60c45ec5e 37 minutes ago 64.2MB
root@hwy:~# docker push wyhwang/test_commit
The push refers to repository [docker.io/wyhwang/test_commit]
ecd5f9c09d7f: Pushed
122be11ab4a2: Mounted from library/ubuntu
7beb13bce073: Mounted from library/ubuntu
f7eae43028b3: Mounted from library/ubuntu
6cebf3abed5f: Mounted from library/ubuntu
latest: digest: sha256:761c63eecaa66abc156b314275967204c3219e06d442b10a732b4800f41664ff size: 1359
Docker Hub에 이미지를 올리려면 이미지 이름을 <Docker Hub 사용자 계정>/<이미지 이름>:<버전> 형식으로 생성해야 함
Docker practice
docker save
docker load
root@hwy:~# docker save test_commit:0.1 > ./save.tgz
root@hwy:~# ls
git save.tgz
root@hwy:~# docker load < ./save.tgz
Loaded image: test_commit:0.1
root@hwy:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test_commit 0.1 efc60c45ec5e About an hour ago 64.2MB
ubuntu 18.04 549b9b86cb8d 2 weeks ago 64.2MB
test 0.1 70e817b514c4 3 weeks ago 876MB
test_test 0.1 60f9924c8777 3 weeks ago 1.22MB
docker volume prune
docker network prune
docker cp
컨테이너 파일을 호스트로 복사
(또는 그 반대방향)
root@hwy:~# docker run -it test_commit:0.1
root@ea19aba8d286:/# ls
a.txt bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@ea19aba8d286:/# root@hwy:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ea19aba8d286 test_commit:0.1 "/bin/bash" 44 seconds ago Up 42 seconds modest_raman
root@hwy:~# docker cp ea19aba8d286:hello.txt ./
root@hwy:~# ll
total 65092
drwx------ 8 root root 4096 Jan 7 08:15 ./
drwxr-xr-x 24 root root 4096 Jan 6 04:11 ../
-rw------- 1 root root 4741 Jan 6 08:20 .bash_history
-rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc
drwx------ 2 root root 4096 Sep 25 23:59 .cache/
drwx------ 2 root root 4096 Jan 7 07:38 .docker/
drwxr-xr-x 3 root root 4096 Dec 13 01:34 git/
drwx------ 3 root root 4096 Sep 25 23:59 .gnupg/
-rw-r--r-- 1 root root 0 Jan 6 06:30 hello.txt
drwxr-xr-x 3 root root 4096 Sep 26 00:46 .local/
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
-rw-r--r-- 1 root root 66598400 Jan 7 08:08 save.tgz
drwx------ 2 root root 4096 Sep 16 03:34 .ssh/
-rw------- 1 root root 3579 Dec 13 02:02 .viminfo
docker container prune 중지된 모든 컨테이너를 삭제
docker image prune 이름 없는 모든 이미지를 삭제
docker network prune 사용되지 않는 도커 네트워크를 모두 삭제
docker volume prune 컨테이너에서 사용하지 않는 모든 볼륨을 삭제
docker system prune -a 중지된 모든 컨테이너, 미사용 네트워크, 컨테이너에서 사용하지 않는 모든 이미지 삭제
tip
https://github.com/ralfyang/docker_cli_dashboard
curl -sL bit.ly/dcs_0 -o ./dcs
chmod +x dcs
sudo mv ./dcs /usr/bin/dcs
dcs
이미지 모두 압축 저장 : save
압축된 이미지 로드 : load
source : https://github.com/goody80/docker_cli_dashboard
Make Docker Image
Dockerfile 명세 명령어
FROM: 기본 이미지 지정
LABEL: Meta 정보(version, name 등)
RUN: 커맨드 명령 실행 부분
ENV: 환경변수 선언 (도커 실행시 외부 주입 가능)
COPY: Local 디스크의 파일을 컨테이너 내부로 복사
ENTRYPOINT: 런타임시 최종적 실행해야 하는 명령어
EXPOSE: Port mapping
빌드시 캐싱 주의
Make Docker Image – ex1
mkdir sample && cd $_
touch Dockerfile
docker build -t sample:1.0 ./
hyper@hwy:~/sample$ more Dockerfile
FROM centos:centos7
hyper@hwy:~/sample$ docker build -t sample:1.0 ./
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM centos:centos7
centos7: Pulling from library/centos
ab5ef0e58194: Pull complete
Digest: sha256:4a701376d03f6b39b8c2a8f4a8e499441b0d567f9ab9d58e4991de4472fb813c
Status: Downloaded newer image for centos:centos7
---> 5e35e350aded
Successfully built 5e35e350aded
Successfully tagged sample:1.0
Make Docker Image – ex2
vi Dockerfile.mine
docker build -t sample2:0.1 -f Dockerfile.mine .
docker images
docker run -d -p 80:80 sample2:0.1
curl http://localhost
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y -q nginx
COPY index.html /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
HomeWork : https://khj93.tistory.com/entry/Docker-Docker-File-%EC%9E%91%EC%84%B1%ED%95%98%EA%B8%B0-%EB%AA%85%EB%A0%B9%EC%96%B4
Docker Compose
여러 컨테이너를 모아서 관리하기 위한 도구
docker-compose.yml 파일에 컨테이너 구성 정보를 정의
image: 사용할 docker image
volumes: container에 mount 할 호스트 볼륨
entrypoint: container load 이후 실행할 명령어
links: container dependency
ports: port mapping
environment: container 내부 환경변수
spring boot application + mysql
Dockerfile practice
simple spring boot application
git clone https://github.com/chathurangat/spring-boot-data-jpa-example.git
mvn clean install -DskipTests (해당 프로젝트 디렉토리에서…)
java -jar target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar
source : https://springbootdev.com/2017/11/13/spring-boot-and-mysql-simple-crud-application-rest-apis-with-spring-data-jpa/
mysql 서비스가 현재 없으므로, 에러가 발생
apt-get install maven
mysql docker launch
docker run -d 
-p 3306:3306 
--name mysql-docker-container 
-e MYSQL_ROOT_PASSWORD=root123 
-e MYSQL_DATABASE=spring_app_db 
-e MYSQL_USER=app_user 
-e MYSQL_PASSWORD=test123 
mysql:5.7
상기 정보에 맞춰서 spring boot application의 application.properties 정보를 수정한다.
spring.datasource.url = jdbc:mysql://mysql-docker-container:3306/spring_app_db?useSSL=false
spring.datasource.username = app_user
spring.datasource.password = test123
source https://springbootdev.com/2017/11/30/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-without-docker-compose/
make Dockerfile
FROM java:8
LABEL maintainer=“test@gmail.com”
VOLUME /tmp
EXPOSE 8080
ADD target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"]
이전 장에서 어플리케이션 속성을 변경했으므로 다시 빌드한다.
mvn clean install -DskipTests
상기 Dockerfile을 빌드한다.
docker build -f Dockerfile -t spring-jpa-app .
빌드한 docker image를 container로 띄운다.
docker run -t --name spring-jpa-app-container --link mysql-docker-container:mysql -p 8087:8080 spring-jpa-app
root@hwy:/home/hyper/app# more Dockerfile
FROM java:8
LABEL maintainer=“test@gmail.com”
VOLUME /tmp
EXPOSE 8080
ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-ex
ample-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"]
source https://springbootdev.com/2017/11/30/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-without-docker-compose/
validation
curl http://localhost:8087/api/users 로 서비스 확인
docker exec -it spring-jpa-app-container bash 로 어플리케이션 컨테이너 접속 etc/hosts 정보 확인
docker exec -it mysql-docker-container bash로 mysql 컨테이너 접속하여 etc/hosts 정보 확인
데이터베이스 확인
curl http://localhost:8087/api/users
[]
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 14
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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>
source https://springbootdev.com/2017/11/30/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-without-docker-compose/
여기서 잠깐…
root@hwy:/home/hyper/app# more Dockerfile
FROM java:8
LABEL maintainer=“test@gmail.com”
VOLUME /tmp
EXPOSE 8080
ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-ex
ample-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"]
drwxrwxrwt 7 root root 4096 Jan 13 10:41 ./
drwxr-xr-x 3 root root 4096 Jan 10 08:24 ../
-rw-r--r-- 1 root root 0 Jan 13 10:41 aaaaaa
drwxr-xr-x 2 root root 4096 Jan 13 10:19 hsperfdata_root/
drwxr-xr-x 3 root root 4096 Jan 10 08:24 tomcat.4873343804251809410.8080/
drwxr-xr-x 3 root root 4096 Jan 13 10:19 tomcat.5421945121563885156.8080/
drwxr-xr-x 2 root root 4096 Jan 13 10:19 tomcat-docbase.4817131992489541769.8080/
drwxr-xr-x 2 root root 4096 Jan 10 08:24 tomcat-docbase.5170213756812424881.8080/
root@hwy:/var/lib/docker/volumes/0ef48eecf67e931101a3196725f09afaf784a176db90bd4660796c2f0781855f/_data#
<host>
root@hwy:/var/lib/docker/volumes/0ef48eecf67e931101a3196725f09afaf784a176db90bd4660796c2f0781855f/_data# docker exec -it spring-jpa-app-container bash
root@54a20f888946:/# cd tmp
root@54a20f888946:/tmp# ls -al
total 28
drwxrwxrwt 7 root root 4096 Jan 13 10:41 .
drwxr-xr-x 1 root root 4096 Jan 10 08:24 ..
-rw-r--r-- 1 root root 0 Jan 13 10:41 aaaaaa
drwxr-xr-x 2 root root 4096 Jan 13 10:19 hsperfdata_root
drwxr-xr-x 2 root root 4096 Jan 13 10:19 tomcat-docbase.4817131992489541769.8080
drwxr-xr-x 2 root root 4096 Jan 10 08:24 tomcat-docbase.5170213756812424881.8080
drwxr-xr-x 3 root root 4096 Jan 10 08:24 tomcat.4873343804251809410.8080
drwxr-xr-x 3 root root 4096 Jan 13 10:19 tomcat.5421945121563885156.8080
<container>
Docker-compose Practice
https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-
jpa-mysql-rest-api-example-with-docker-with-docker-compose/
root@hwy:/home/hyper/app# more spring-boot-data-jpa-example/src/main/resources/application.properties
## Spring DATA SOURCE Configurations
spring.datasource.url = jdbc:mysql://mysql-docker-container-dc:3306/spring_app_db?useSSL=false
spring.datasource.username = app_user
spring.datasource.password = test123
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
root@hwy:/home/hyper/app#
root@hwy:/home/hyper/app/spring-boot-data-jpa-example# !688
mvn clean install -DskipTests
source : https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-with-docker-compose/
https://asciinema.org/a/FoUFk1TwzZHu3szzbRnqkxOzI
Docker Image Build
root@hwy:/home/hyper/app# !690
docker build -f Dockerfile -t spring-jpa-app-dc .
Sending build context to Docker daemon 28.27MB
Step 1/6 : FROM java:8
---> d23bdf5b1b1b
Step 2/6 : LABEL maintainer=“chathuranga.t@gmail.com”
---> Using cache
---> c27c7776faaa
Step 3/6 : VOLUME /tmp
---> Using cache
---> c2e331f7a760
Step 4/6 : EXPOSE 8080
---> Using cache
---> 19d42b538e86
Step 5/6 : ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar
---> a145818b2e61
Step 6/6 : ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"]
---> Running in 0b802f4d0d7f
Removing intermediate container 0b802f4d0d7f
---> a2a2ca8f6856
Successfully built a2a2ca8f6856
Successfully tagged spring-jpa-app-dc:latest
source : https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-with-docker-compose/
Docker compose build
root@hwy:/home/hyper/app# more docker-compose.yml
version: '3'
services:
mysql-docker-container-dc:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=root123
- MYSQL_DATABASE=spring_app_db
- MYSQL_USER=app_user
- MYSQL_PASSWORD=test123
volumes:
- /data/mysql
ports:
- 3307:3306
spring-boot-jpa-app-dc:
image: spring-jpa-app-dc
build:
context: ./
dockerfile: Dockerfile
depends_on:
- mysql-docker-container-dc
ports:
- 8088:8080
volumes:
- /data/spring-boot-app
spring.datasource.url = jdbc:mysql://mysql-docker-container-dc:3306/spring_app_db?useSSL=false
root@hwy:/home/hyper/app# more Dockerfile
FROM java:8
LABEL maintainer=“chathuranga.t@gmail.com”
VOLUME /tmp
EXPOSE 8080
ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"]
docker-compose build
docker-compose up
source : https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-with-docker-compose/
The image name is “spring-boot-jpa-image“. If the image does not exist, it should be built with the Dockerfile available in the current working directory.
introduction of rancher
rancher
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
rancher
root@hwy:~# docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
Unable to find image 'rancher/rancher:latest' locally
latest: Pulling from rancher/rancher
5c939e3a4d10: Pull complete
c63719cdbe7a: Pull complete
19a861ea6baf: Pull complete
651c9d2d6c4f: Pull complete
59bb35af0b6d: Pull complete
f5999074359c: Pull complete
d14caaf640e8: Pull complete
8ccae3cb1601: Pull complete
4062406df3de: Pull complete
f40fe908462d: Pull complete
3ddd5a6a2e2f: Pull complete
a72a2a6a0a32: Pull complete
b7f0c1ee9978: Pull complete
52dccda38c45: Pull complete
Digest: sha256:b5c473fa93552724c3e0a11203ea51449cf1c56de688a9b7d0147aa126fbeb8b
Status: Downloaded newer image for rancher/rancher:latest
dc757b2c7021bb3945a136f79b4842d8ba5d0367fe217a05c0f2f604e9e8fa10
Docker practice
Docker practice
rancher (add cluster) agent installation, communication with rancher host
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/deployment/quickstart-manual-setup/
Docker practice
Workload with NodePort Quick Start
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
Workload with NodePort Quick Start
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
Workload with NodePort Quick Start
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
root@hwy:/home/hyper/sample# curl http://10.42.0.8
… 생 략 …
<body>
<img id="logo" src="img/rancher-logo.svg" alt="Rancher logo" width=400 />
<h1>Hello world!</h1>
<h3>My hostname is here-86cdfb6c85-5pnxz</h3>
<div id='Services'>
<h3>k8s services found 1</h3>
<b>KUBERNETES</b> tcp://10.43.0.1:443<br />
</div>
<br />
<div id='rancherLinks' class="row social">
<a class="p-a-xs" href="https://rancher.com/docs"><img src="img/favicon.png" alt="Docs" height="25" width="25"></a>
<a class="p-a-xs" href="https://slack.rancher.io/"><img src="img/icon-slack.svg" alt="slack" height="25" width="25"></a>
<a class="p-a-xs" href="https://github.com/rancher/rancher"><img src="img/icon-github.svg" alt="github" height="25" width="25"></a>
<a class="p-a-xs" href="https://twitter.com/Rancher_Labs"><img src="img/icon-twitter.svg" alt="twitter" height="25" width="25"></a>
<a class="p-a-xs" href="https://www.facebook.com/rancherlabs/"><img src="img/icon-facebook.svg" alt="facebook" height="25" width="25"></a>
<a class="p-a-xs" href="https://www.linkedin.com/groups/6977008/profile"><img src="img/icon-linkedin.svg" height="25" alt="linkedin" width="25"></a>
</div>
<br />
<button class='button' onclick='myFunction()'>Show request details</button>
<div id="reqInfo" style='display:none'>
<h3>Request info</h3>
<b>Host:</b> 10.42.0.8 <br />
<b>Pod:</b> here-86cdfb6c85-5pnxz </b><br />
<b>Accept:</b> [*/*]<br />
<b>User-Agent:</b> [curl/7.58.0]<br />
</div>
<br />
… 생 략 …
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
Workload with NodePort Quick Start
deploying a workload
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-ingress/
Expose The Application Via An Ingress
source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-ingress/
Expose The Application Via An Ingress
troubleshooting
[controlPlane] Failed to bring up Control Plane: [Failed to create [kube-apiserver]
container on host [10.0.2.15]: Failed to create Docker container [kube-apiserver]
on host [10.0.2.15]: <nil>]
수동으로 관련 이미지 pull 하였을 경우(docker pull
rancher/hyperkube:v1.17.0-rancher1),
failed to register layer: Error processing tar file(exit status 1): write
/opt/az/lib/python3.6/site-
packages/azure/mgmt/web/models/__pycache__/certificate_details.cpython-
36.pyc: no space left on device
에러 발생하여, 아래 내용 수행하여 해결
docker system df
If RECLAIMABLE amount is greater than zero (that would definitely the case)
then run command
docker system prune -a

Contenu connexe

Tendances

Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Ben Hall
 
Docker Setting for Static IP allocation
Docker Setting for Static IP allocationDocker Setting for Static IP allocation
Docker Setting for Static IP allocationJi-Woong Choi
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)Ruoshi Ling
 
Docker orchestration v4
Docker orchestration v4Docker orchestration v4
Docker orchestration v4Hojin Kim
 
Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersBen Hall
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Ben Hall
 
Lessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containersLessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containersBen Hall
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Composeraccoony
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Ben Hall
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點William Yeh
 
DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains  DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains Docker, Inc.
 
Component pack 6006 install guide
Component pack 6006 install guideComponent pack 6006 install guide
Component pack 6006 install guideRoberto Boccadoro
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeSoshi Nemoto
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Running .NET on Docker
Running .NET on DockerRunning .NET on Docker
Running .NET on DockerBen Hall
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingOpen Source Consulting
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionBen Hall
 
Docker security
Docker securityDocker security
Docker securityJanos Suto
 

Tendances (20)

Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Docker Setting for Static IP allocation
Docker Setting for Static IP allocationDocker Setting for Static IP allocation
Docker Setting for Static IP allocation
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
 
Docker orchestration v4
Docker orchestration v4Docker orchestration v4
Docker orchestration v4
 
Lessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containersLessons from running potentially malicious code inside containers
Lessons from running potentially malicious code inside containers
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Lessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containersLessons from running potentially malicious code inside Docker containers
Lessons from running potentially malicious code inside Docker containers
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點
 
DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains  DCSF19 Tips and Tricks of the Docker Captains
DCSF19 Tips and Tricks of the Docker Captains
 
Component pack 6006 install guide
Component pack 6006 install guideComponent pack 6006 install guide
Component pack 6006 install guide
 
Nginx2
Nginx2Nginx2
Nginx2
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Running .NET on Docker
Running .NET on DockerRunning .NET on Docker
Running .NET on Docker
 
Ex200
Ex200Ex200
Ex200
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource Consulting
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Docker security
Docker securityDocker security
Docker security
 

Similaire à Docker practice

Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session DockerLinetsChile
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with dockerJohan Janssen
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨Ruoshi Ling
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by DockerTerry Chen
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions Chanaka Lasantha
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachPROIDEA
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...Docker, Inc.
 
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...Christy Norman
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker皓鈞 張
 
DeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to DockerDeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to DockerSteve Smith
 
Azure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiAzure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiGirish Kalamati
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Praguetomasbart
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby IntroductionTyler Johnston
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
 
Docker in Action
Docker in ActionDocker in Action
Docker in ActionAlper Kanat
 

Similaire à Docker practice (20)

Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
 
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
DeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to DockerDeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to Docker
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker orchestration
Docker orchestrationDocker orchestration
Docker orchestration
 
Azure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish KalamatiAzure from scratch part 5 By Girish Kalamati
Azure from scratch part 5 By Girish Kalamati
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby Introduction
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Docker
DockerDocker
Docker
 

Plus de wonyong hwang

Hyperledger Explorer.pptx
Hyperledger Explorer.pptxHyperledger Explorer.pptx
Hyperledger Explorer.pptxwonyong hwang
 
하이퍼레저 페이지 단위 블록 조회
하이퍼레저 페이지 단위 블록 조회하이퍼레저 페이지 단위 블록 조회
하이퍼레저 페이지 단위 블록 조회wonyong hwang
 
토큰 증권 개요.pptx
토큰 증권 개요.pptx토큰 증권 개요.pptx
토큰 증권 개요.pptxwonyong hwang
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptxwonyong hwang
 
Deploying Hyperledger Fabric on Kubernetes.pptx
Deploying Hyperledger Fabric on Kubernetes.pptxDeploying Hyperledger Fabric on Kubernetes.pptx
Deploying Hyperledger Fabric on Kubernetes.pptxwonyong hwang
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptxwonyong hwang
 
HyperLedger Fabric V2.5.pdf
HyperLedger Fabric V2.5.pdfHyperLedger Fabric V2.5.pdf
HyperLedger Fabric V2.5.pdfwonyong hwang
 
Ngrok을 이용한 Nginx Https 적용하기.pptx
Ngrok을 이용한 Nginx Https 적용하기.pptxNgrok을 이용한 Nginx Https 적용하기.pptx
Ngrok을 이용한 Nginx Https 적용하기.pptxwonyong hwang
 
Nginx Https 적용하기.pptx
Nginx Https 적용하기.pptxNginx Https 적용하기.pptx
Nginx Https 적용하기.pptxwonyong hwang
 
Kafka JDBC Connect Guide(Postgres Sink).pptx
Kafka JDBC Connect Guide(Postgres Sink).pptxKafka JDBC Connect Guide(Postgres Sink).pptx
Kafka JDBC Connect Guide(Postgres Sink).pptxwonyong hwang
 
Nginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxNginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxwonyong hwang
 
Kafka monitoring using Prometheus and Grafana
Kafka monitoring using Prometheus and GrafanaKafka monitoring using Prometheus and Grafana
Kafka monitoring using Prometheus and Grafanawonyong hwang
 
주가 정보 다루기.pdf
주가 정보 다루기.pdf주가 정보 다루기.pdf
주가 정보 다루기.pdfwonyong hwang
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)wonyong hwang
 
Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) wonyong hwang
 
Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)wonyong hwang
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by pythonwonyong hwang
 

Plus de wonyong hwang (20)

Hyperledger Explorer.pptx
Hyperledger Explorer.pptxHyperledger Explorer.pptx
Hyperledger Explorer.pptx
 
하이퍼레저 페이지 단위 블록 조회
하이퍼레저 페이지 단위 블록 조회하이퍼레저 페이지 단위 블록 조회
하이퍼레저 페이지 단위 블록 조회
 
토큰 증권 개요.pptx
토큰 증권 개요.pptx토큰 증권 개요.pptx
토큰 증권 개요.pptx
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptx
 
Deploying Hyperledger Fabric on Kubernetes.pptx
Deploying Hyperledger Fabric on Kubernetes.pptxDeploying Hyperledger Fabric on Kubernetes.pptx
Deploying Hyperledger Fabric on Kubernetes.pptx
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
 
HyperLedger Fabric V2.5.pdf
HyperLedger Fabric V2.5.pdfHyperLedger Fabric V2.5.pdf
HyperLedger Fabric V2.5.pdf
 
Ngrok을 이용한 Nginx Https 적용하기.pptx
Ngrok을 이용한 Nginx Https 적용하기.pptxNgrok을 이용한 Nginx Https 적용하기.pptx
Ngrok을 이용한 Nginx Https 적용하기.pptx
 
Nginx Https 적용하기.pptx
Nginx Https 적용하기.pptxNginx Https 적용하기.pptx
Nginx Https 적용하기.pptx
 
Kafka JDBC Connect Guide(Postgres Sink).pptx
Kafka JDBC Connect Guide(Postgres Sink).pptxKafka JDBC Connect Guide(Postgres Sink).pptx
Kafka JDBC Connect Guide(Postgres Sink).pptx
 
Nginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxNginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptx
 
Kafka Rest.pptx
Kafka Rest.pptxKafka Rest.pptx
Kafka Rest.pptx
 
Kafka monitoring using Prometheus and Grafana
Kafka monitoring using Prometheus and GrafanaKafka monitoring using Prometheus and Grafana
Kafka monitoring using Prometheus and Grafana
 
주가 정보 다루기.pdf
주가 정보 다루기.pdf주가 정보 다루기.pdf
주가 정보 다루기.pdf
 
KAFKA 3.1.0.pdf
KAFKA 3.1.0.pdfKAFKA 3.1.0.pdf
KAFKA 3.1.0.pdf
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)
 
Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0)
 
Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)
 
Kafka slideshare
Kafka   slideshareKafka   slideshare
Kafka slideshare
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 

Dernier

Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageDista
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.Sharon Liu
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
React 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentReact 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentBOSC Tech Labs
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)Jonathan Katz
 
How to Improve the Employee Experience? - HRMS Software
How to Improve the Employee Experience? - HRMS SoftwareHow to Improve the Employee Experience? - HRMS Software
How to Improve the Employee Experience? - HRMS SoftwareNYGGS Automation Suite
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesShyamsundar Das
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionsNirav Modi
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 

Dernier (20)

Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
React 19: Revolutionizing Web Development
React 19: Revolutionizing Web DevelopmentReact 19: Revolutionizing Web Development
React 19: Revolutionizing Web Development
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)Vectors are the new JSON in PostgreSQL (SCaLE 21x)
Vectors are the new JSON in PostgreSQL (SCaLE 21x)
 
How to Improve the Employee Experience? - HRMS Software
How to Improve the Employee Experience? - HRMS SoftwareHow to Improve the Employee Experience? - HRMS Software
How to Improve the Employee Experience? - HRMS Software
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security Challenges
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspections
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 

Docker practice

  • 2. Precondition Ubuntu 18.04 LTS or Above Docker Install (Latest version) apt-get install libltdl-dev Docker Engine: Version 17.06.2-ce or higher wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/do cker-ce_17.06.2~ce-0~ubuntu_amd64.deb dpkg -i docker-ce_17.06.2~ce-0~ubuntu_amd64.deb docker —version curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker- compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose docker–compose –versionhttps://phoenixnap.com/kb/install-docker-compose-ubuntu
  • 3. Docker? 별도 Process 적층형 이미지 출처: https://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal https://2eof2j3oc7is20vt9q3g7tlo5xe-wpengine.netdna-ssl.com/wp-content/uploads/2014/08/ibm-various-virtualization.jpg
  • 4. 기본 명령어 sudo docker version docker images root@hwy:~# docker version Client: Docker Engine - Community Version: 19.03.2 API version: 1.40 Go version: go1.12.8 Git commit: 6a30dfc Built: Thu Aug 29 05:29:11 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.2 API version: 1.40 (minimum version 1.12) Go version: go1.12.8 Git commit: 6a30dfc Built: Thu Aug 29 05:27:45 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.6 GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc: Version: 1.0.0-rc8 GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f docker-init: Version: 0.18.0 GitCommit: fec3683 root@hwy:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE test 0.1 70e817b514c4 3 weeks ago 876MB test_test 0.1 60f9924c8777 3 weeks ago 1.22MB busybox latest b534869c81f0 4 weeks ago 1.22MB ubuntu 16.04 56bab49eef2e 5 weeks ago 123MB mysql 5.7 1e4405fe1ea9 6 weeks ago 437MB nginx latest 231d40e811cd 6 weeks ago 126MB
  • 5. docker pull docker search root@hwy:~# docker pull ubuntu:18.04 18.04: Pulling from library/ubuntu 2746a4a261c9: Pull complete 4c1d20cdee96: Pull complete 0d3160e1d0de: Pull complete c8e37668deea: Pull complete Digest: sha256:250cc6f3f3ffc5cdaa9d8f4946ac79821aafb4d3afc93928f0de9336eba21aa4 Status: Downloaded newer image for ubuntu:18.04 docker.io/library/ubuntu:18.04 root@hwy:~# docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating sys… 10328 [OK] dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 381 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 239 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 203 [OK] ubuntu-upstart Upstart is an event-based replacement for th… 102 [OK] ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 98 [OK] neurodebian NeuroDebian provides neuroscience research s… 63 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components=m… 41 [OK] nuagebec/ubuntu Simple always updated Ubuntu docker images w… 24 [OK] i386/ubuntu Ubuntu is a Debian-based Linux operating sys… 18 1and1internet/ubuntu-16-apache-php-5.6 ubuntu-16-apache-php-5.6 14 [OK] 1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 13 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10 ubuntu-16-nginx-php-phpmyadmin-mariadb-10 11 [OK] …
  • 7. root@hwy:~# docker run -i -t ubuntu:latest /bin/bash (i : interactive(사용자 입출력), t: tty) exit 입력 -> container 종료 root@hwy:~# docker run -i -t ubuntu:latest /bin/bash root@c7c709ecddb6:/# root@c7c709ecddb6:/# uname -a Linux c7c709ecddb6 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux root@c7c709ecddb6:/# whoami root root@c7c709ecddb6:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@c7c709ecddb6:/# root@c7c709ecddb6:/# root@c7c709ecddb6:/# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 04:53 pts/0 00:00:00 /bin/bash root 13 1 0 04:56 pts/0 00:00:00 ps -ef root@c7c709ecddb6:/#
  • 8. docker ps docker start  without shell docker attach root@hwy:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c7c709ecddb6 ubuntu:latest "/bin/bash" 5 minutes ago Exited (127) 5 seconds ago unruffled_leakey root@hwy:~# docker start unruffled_leakey unruffled_leakey root@hwy:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c7c709ecddb6 ubuntu:latest "/bin/bash" 7 minutes ago Up 13 seconds unruffled_leakey ※ docker run = 컨테이너 생성 + docker start + docker attach root@hwy:~# docker attach unruffled_leakey root@c7c709ecddb6:/# attach 된 상태에서 exit하면 container 가 종료됨 container를 종료하지 않고 쉘에서 빠져나오려면 Ctrl + P,Q root@c7c709ecddb6:/# read escape sequence root@hwy:~# docker ps CONTAINER ID IMAGE COMMAND CREATED c7c709ecddb6 ubuntu:latest "/bin/bash" 17 minutes ago
  • 9. docker stop docker rm [이름]  컨테이너 삭제 docker rmi [리포지토리 이름]  이미지 삭제 root@hwy:~# docker stop unruffled_leakey unruffled_leakey root@hwy:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES root@hwy:~#
  • 10. root@hwy:~# docker run -d --name mynginx nginx 03a6c48083eb256d65f21f056a6080e288f2ac071854fb24c1a95c9b82bdb6a4 docker run -d --name mynginx -p 8000:80 nginx root@hwy:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 03a6c48083eb nginx "nginx -g 'daemon of…" 8 seconds ago Up 6 seconds 80/tcp mynginx -d detached 옵션으로 백그라운드로 실행 -p 포트맵핑 서버 포트 : 컨테이너 포트
  • 11. docker exec root@hwy:~# docker run -i -t --name hello ubuntu /bin/bash root@hwy:~# docker exec hello echo 1 root@hwy:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6a3d2aa1a1e3 ubuntu "/bin/bash" 59 seconds ago Up 57 seconds hello 2d35fa16ce28 nginx "nginx -g 'daemon of…" 16 minutes ago Up 16 minutes 0.0.0.0:8000->80/tcp mynginx root@hwy:~# docker exec hello touch /hello.txt root@hwy:~# docker attach hello root@6a3d2aa1a1e3:/# ls / bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
  • 12. docker commit root@hwy:~# docker commit 6a3d2aa1a1e3 test_commit:0.1 sha256:efc60c45ec5e59646e1a98e583ea930e7b37b1e0c742b20b2d1e34e46bec71b5 root@hwy:~# docker images root@hwy:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE test_commit 0.1 efc60c45ec5e 6 seconds ago 64.2MB root@hwy:~# docker run -it test_commit:0.1 root@d6aee93a68f0:/# ls / a.txt bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
  • 13. docker login docker logout docker tag docker push root@hwy:~# docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: wyhwang Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded root@hwy:~# docker tag test_commit:0.1 wyhwang/test_commit:latest root@hwy:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE wyhwang/test_commit latest efc60c45ec5e 37 minutes ago 64.2MB test_commit 0.1 efc60c45ec5e 37 minutes ago 64.2MB root@hwy:~# docker push wyhwang/test_commit The push refers to repository [docker.io/wyhwang/test_commit] ecd5f9c09d7f: Pushed 122be11ab4a2: Mounted from library/ubuntu 7beb13bce073: Mounted from library/ubuntu f7eae43028b3: Mounted from library/ubuntu 6cebf3abed5f: Mounted from library/ubuntu latest: digest: sha256:761c63eecaa66abc156b314275967204c3219e06d442b10a732b4800f41664ff size: 1359 Docker Hub에 이미지를 올리려면 이미지 이름을 <Docker Hub 사용자 계정>/<이미지 이름>:<버전> 형식으로 생성해야 함
  • 15. docker save docker load root@hwy:~# docker save test_commit:0.1 > ./save.tgz root@hwy:~# ls git save.tgz root@hwy:~# docker load < ./save.tgz Loaded image: test_commit:0.1 root@hwy:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE test_commit 0.1 efc60c45ec5e About an hour ago 64.2MB ubuntu 18.04 549b9b86cb8d 2 weeks ago 64.2MB test 0.1 70e817b514c4 3 weeks ago 876MB test_test 0.1 60f9924c8777 3 weeks ago 1.22MB
  • 16. docker volume prune docker network prune docker cp 컨테이너 파일을 호스트로 복사 (또는 그 반대방향) root@hwy:~# docker run -it test_commit:0.1 root@ea19aba8d286:/# ls a.txt bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@ea19aba8d286:/# root@hwy:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ea19aba8d286 test_commit:0.1 "/bin/bash" 44 seconds ago Up 42 seconds modest_raman root@hwy:~# docker cp ea19aba8d286:hello.txt ./ root@hwy:~# ll total 65092 drwx------ 8 root root 4096 Jan 7 08:15 ./ drwxr-xr-x 24 root root 4096 Jan 6 04:11 ../ -rw------- 1 root root 4741 Jan 6 08:20 .bash_history -rw-r--r-- 1 root root 3106 Apr 9 2018 .bashrc drwx------ 2 root root 4096 Sep 25 23:59 .cache/ drwx------ 2 root root 4096 Jan 7 07:38 .docker/ drwxr-xr-x 3 root root 4096 Dec 13 01:34 git/ drwx------ 3 root root 4096 Sep 25 23:59 .gnupg/ -rw-r--r-- 1 root root 0 Jan 6 06:30 hello.txt drwxr-xr-x 3 root root 4096 Sep 26 00:46 .local/ -rw-r--r-- 1 root root 148 Aug 17 2015 .profile -rw-r--r-- 1 root root 66598400 Jan 7 08:08 save.tgz drwx------ 2 root root 4096 Sep 16 03:34 .ssh/ -rw------- 1 root root 3579 Dec 13 02:02 .viminfo docker container prune 중지된 모든 컨테이너를 삭제 docker image prune 이름 없는 모든 이미지를 삭제 docker network prune 사용되지 않는 도커 네트워크를 모두 삭제 docker volume prune 컨테이너에서 사용하지 않는 모든 볼륨을 삭제 docker system prune -a 중지된 모든 컨테이너, 미사용 네트워크, 컨테이너에서 사용하지 않는 모든 이미지 삭제
  • 17. tip https://github.com/ralfyang/docker_cli_dashboard curl -sL bit.ly/dcs_0 -o ./dcs chmod +x dcs sudo mv ./dcs /usr/bin/dcs dcs 이미지 모두 압축 저장 : save 압축된 이미지 로드 : load source : https://github.com/goody80/docker_cli_dashboard
  • 18. Make Docker Image Dockerfile 명세 명령어 FROM: 기본 이미지 지정 LABEL: Meta 정보(version, name 등) RUN: 커맨드 명령 실행 부분 ENV: 환경변수 선언 (도커 실행시 외부 주입 가능) COPY: Local 디스크의 파일을 컨테이너 내부로 복사 ENTRYPOINT: 런타임시 최종적 실행해야 하는 명령어 EXPOSE: Port mapping 빌드시 캐싱 주의
  • 19. Make Docker Image – ex1 mkdir sample && cd $_ touch Dockerfile docker build -t sample:1.0 ./ hyper@hwy:~/sample$ more Dockerfile FROM centos:centos7 hyper@hwy:~/sample$ docker build -t sample:1.0 ./ Sending build context to Docker daemon 2.048kB Step 1/1 : FROM centos:centos7 centos7: Pulling from library/centos ab5ef0e58194: Pull complete Digest: sha256:4a701376d03f6b39b8c2a8f4a8e499441b0d567f9ab9d58e4991de4472fb813c Status: Downloaded newer image for centos:centos7 ---> 5e35e350aded Successfully built 5e35e350aded Successfully tagged sample:1.0
  • 20. Make Docker Image – ex2 vi Dockerfile.mine docker build -t sample2:0.1 -f Dockerfile.mine . docker images docker run -d -p 80:80 sample2:0.1 curl http://localhost FROM ubuntu:latest RUN apt-get update RUN apt-get install -y -q nginx COPY index.html /usr/share/nginx/html CMD ["nginx", "-g", "daemon off;"] HomeWork : https://khj93.tistory.com/entry/Docker-Docker-File-%EC%9E%91%EC%84%B1%ED%95%98%EA%B8%B0-%EB%AA%85%EB%A0%B9%EC%96%B4
  • 21. Docker Compose 여러 컨테이너를 모아서 관리하기 위한 도구 docker-compose.yml 파일에 컨테이너 구성 정보를 정의 image: 사용할 docker image volumes: container에 mount 할 호스트 볼륨 entrypoint: container load 이후 실행할 명령어 links: container dependency ports: port mapping environment: container 내부 환경변수
  • 22. spring boot application + mysql Dockerfile practice
  • 23. simple spring boot application git clone https://github.com/chathurangat/spring-boot-data-jpa-example.git mvn clean install -DskipTests (해당 프로젝트 디렉토리에서…) java -jar target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar source : https://springbootdev.com/2017/11/13/spring-boot-and-mysql-simple-crud-application-rest-apis-with-spring-data-jpa/ mysql 서비스가 현재 없으므로, 에러가 발생 apt-get install maven
  • 24. mysql docker launch docker run -d -p 3306:3306 --name mysql-docker-container -e MYSQL_ROOT_PASSWORD=root123 -e MYSQL_DATABASE=spring_app_db -e MYSQL_USER=app_user -e MYSQL_PASSWORD=test123 mysql:5.7 상기 정보에 맞춰서 spring boot application의 application.properties 정보를 수정한다. spring.datasource.url = jdbc:mysql://mysql-docker-container:3306/spring_app_db?useSSL=false spring.datasource.username = app_user spring.datasource.password = test123 source https://springbootdev.com/2017/11/30/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-without-docker-compose/
  • 25. make Dockerfile FROM java:8 LABEL maintainer=“test@gmail.com” VOLUME /tmp EXPOSE 8080 ADD target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"] 이전 장에서 어플리케이션 속성을 변경했으므로 다시 빌드한다. mvn clean install -DskipTests 상기 Dockerfile을 빌드한다. docker build -f Dockerfile -t spring-jpa-app . 빌드한 docker image를 container로 띄운다. docker run -t --name spring-jpa-app-container --link mysql-docker-container:mysql -p 8087:8080 spring-jpa-app root@hwy:/home/hyper/app# more Dockerfile FROM java:8 LABEL maintainer=“test@gmail.com” VOLUME /tmp EXPOSE 8080 ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-ex ample-0.0.1-SNAPSHOT.jar ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"] source https://springbootdev.com/2017/11/30/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-without-docker-compose/
  • 26. validation curl http://localhost:8087/api/users 로 서비스 확인 docker exec -it spring-jpa-app-container bash 로 어플리케이션 컨테이너 접속 etc/hosts 정보 확인 docker exec -it mysql-docker-container bash로 mysql 컨테이너 접속하여 etc/hosts 정보 확인 데이터베이스 확인 curl http://localhost:8087/api/users [] mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 14 Server version: 5.7.28 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. 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> source https://springbootdev.com/2017/11/30/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-without-docker-compose/
  • 27. 여기서 잠깐… root@hwy:/home/hyper/app# more Dockerfile FROM java:8 LABEL maintainer=“test@gmail.com” VOLUME /tmp EXPOSE 8080 ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-ex ample-0.0.1-SNAPSHOT.jar ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"] drwxrwxrwt 7 root root 4096 Jan 13 10:41 ./ drwxr-xr-x 3 root root 4096 Jan 10 08:24 ../ -rw-r--r-- 1 root root 0 Jan 13 10:41 aaaaaa drwxr-xr-x 2 root root 4096 Jan 13 10:19 hsperfdata_root/ drwxr-xr-x 3 root root 4096 Jan 10 08:24 tomcat.4873343804251809410.8080/ drwxr-xr-x 3 root root 4096 Jan 13 10:19 tomcat.5421945121563885156.8080/ drwxr-xr-x 2 root root 4096 Jan 13 10:19 tomcat-docbase.4817131992489541769.8080/ drwxr-xr-x 2 root root 4096 Jan 10 08:24 tomcat-docbase.5170213756812424881.8080/ root@hwy:/var/lib/docker/volumes/0ef48eecf67e931101a3196725f09afaf784a176db90bd4660796c2f0781855f/_data# <host> root@hwy:/var/lib/docker/volumes/0ef48eecf67e931101a3196725f09afaf784a176db90bd4660796c2f0781855f/_data# docker exec -it spring-jpa-app-container bash root@54a20f888946:/# cd tmp root@54a20f888946:/tmp# ls -al total 28 drwxrwxrwt 7 root root 4096 Jan 13 10:41 . drwxr-xr-x 1 root root 4096 Jan 10 08:24 .. -rw-r--r-- 1 root root 0 Jan 13 10:41 aaaaaa drwxr-xr-x 2 root root 4096 Jan 13 10:19 hsperfdata_root drwxr-xr-x 2 root root 4096 Jan 13 10:19 tomcat-docbase.4817131992489541769.8080 drwxr-xr-x 2 root root 4096 Jan 10 08:24 tomcat-docbase.5170213756812424881.8080 drwxr-xr-x 3 root root 4096 Jan 10 08:24 tomcat.4873343804251809410.8080 drwxr-xr-x 3 root root 4096 Jan 13 10:19 tomcat.5421945121563885156.8080 <container>
  • 28. Docker-compose Practice https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data- jpa-mysql-rest-api-example-with-docker-with-docker-compose/ root@hwy:/home/hyper/app# more spring-boot-data-jpa-example/src/main/resources/application.properties ## Spring DATA SOURCE Configurations spring.datasource.url = jdbc:mysql://mysql-docker-container-dc:3306/spring_app_db?useSSL=false spring.datasource.username = app_user spring.datasource.password = test123 ## Hibernate Properties # The SQL dialect makes Hibernate generate better SQL for the chosen database spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect # Hibernate ddl auto (create, create-drop, validate, update) spring.jpa.hibernate.ddl-auto = update root@hwy:/home/hyper/app# root@hwy:/home/hyper/app/spring-boot-data-jpa-example# !688 mvn clean install -DskipTests source : https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-with-docker-compose/ https://asciinema.org/a/FoUFk1TwzZHu3szzbRnqkxOzI
  • 29. Docker Image Build root@hwy:/home/hyper/app# !690 docker build -f Dockerfile -t spring-jpa-app-dc . Sending build context to Docker daemon 28.27MB Step 1/6 : FROM java:8 ---> d23bdf5b1b1b Step 2/6 : LABEL maintainer=“chathuranga.t@gmail.com” ---> Using cache ---> c27c7776faaa Step 3/6 : VOLUME /tmp ---> Using cache ---> c2e331f7a760 Step 4/6 : EXPOSE 8080 ---> Using cache ---> 19d42b538e86 Step 5/6 : ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar ---> a145818b2e61 Step 6/6 : ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"] ---> Running in 0b802f4d0d7f Removing intermediate container 0b802f4d0d7f ---> a2a2ca8f6856 Successfully built a2a2ca8f6856 Successfully tagged spring-jpa-app-dc:latest source : https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-with-docker-compose/
  • 30. Docker compose build root@hwy:/home/hyper/app# more docker-compose.yml version: '3' services: mysql-docker-container-dc: image: mysql:5.7 environment: - MYSQL_ROOT_PASSWORD=root123 - MYSQL_DATABASE=spring_app_db - MYSQL_USER=app_user - MYSQL_PASSWORD=test123 volumes: - /data/mysql ports: - 3307:3306 spring-boot-jpa-app-dc: image: spring-jpa-app-dc build: context: ./ dockerfile: Dockerfile depends_on: - mysql-docker-container-dc ports: - 8088:8080 volumes: - /data/spring-boot-app spring.datasource.url = jdbc:mysql://mysql-docker-container-dc:3306/spring_app_db?useSSL=false root@hwy:/home/hyper/app# more Dockerfile FROM java:8 LABEL maintainer=“chathuranga.t@gmail.com” VOLUME /tmp EXPOSE 8080 ADD spring-boot-data-jpa-example/target/spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar ENTRYPOINT ["java","-jar","spring-boot-data-jpa-example-0.0.1-SNAPSHOT.jar"] docker-compose build docker-compose up source : https://springbootdev.com/2018/01/08/docker-spring-boot-and-spring-data-jpa-mysql-rest-api-example-with-docker-with-docker-compose/ The image name is “spring-boot-jpa-image“. If the image does not exist, it should be built with the Dockerfile available in the current working directory.
  • 32. rancher docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
  • 33. rancher root@hwy:~# docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher Unable to find image 'rancher/rancher:latest' locally latest: Pulling from rancher/rancher 5c939e3a4d10: Pull complete c63719cdbe7a: Pull complete 19a861ea6baf: Pull complete 651c9d2d6c4f: Pull complete 59bb35af0b6d: Pull complete f5999074359c: Pull complete d14caaf640e8: Pull complete 8ccae3cb1601: Pull complete 4062406df3de: Pull complete f40fe908462d: Pull complete 3ddd5a6a2e2f: Pull complete a72a2a6a0a32: Pull complete b7f0c1ee9978: Pull complete 52dccda38c45: Pull complete Digest: sha256:b5c473fa93552724c3e0a11203ea51449cf1c56de688a9b7d0147aa126fbeb8b Status: Downloaded newer image for rancher/rancher:latest dc757b2c7021bb3945a136f79b4842d8ba5d0367fe217a05c0f2f604e9e8fa10
  • 36. rancher (add cluster) agent installation, communication with rancher host source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/deployment/quickstart-manual-setup/
  • 38. Workload with NodePort Quick Start source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
  • 39. Workload with NodePort Quick Start source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
  • 40. Workload with NodePort Quick Start source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/
  • 41. root@hwy:/home/hyper/sample# curl http://10.42.0.8 … 생 략 … <body> <img id="logo" src="img/rancher-logo.svg" alt="Rancher logo" width=400 /> <h1>Hello world!</h1> <h3>My hostname is here-86cdfb6c85-5pnxz</h3> <div id='Services'> <h3>k8s services found 1</h3> <b>KUBERNETES</b> tcp://10.43.0.1:443<br /> </div> <br /> <div id='rancherLinks' class="row social"> <a class="p-a-xs" href="https://rancher.com/docs"><img src="img/favicon.png" alt="Docs" height="25" width="25"></a> <a class="p-a-xs" href="https://slack.rancher.io/"><img src="img/icon-slack.svg" alt="slack" height="25" width="25"></a> <a class="p-a-xs" href="https://github.com/rancher/rancher"><img src="img/icon-github.svg" alt="github" height="25" width="25"></a> <a class="p-a-xs" href="https://twitter.com/Rancher_Labs"><img src="img/icon-twitter.svg" alt="twitter" height="25" width="25"></a> <a class="p-a-xs" href="https://www.facebook.com/rancherlabs/"><img src="img/icon-facebook.svg" alt="facebook" height="25" width="25"></a> <a class="p-a-xs" href="https://www.linkedin.com/groups/6977008/profile"><img src="img/icon-linkedin.svg" height="25" alt="linkedin" width="25"></a> </div> <br /> <button class='button' onclick='myFunction()'>Show request details</button> <div id="reqInfo" style='display:none'> <h3>Request info</h3> <b>Host:</b> 10.42.0.8 <br /> <b>Pod:</b> here-86cdfb6c85-5pnxz </b><br /> <b>Accept:</b> [*/*]<br /> <b>User-Agent:</b> [curl/7.58.0]<br /> </div> <br /> … 생 략 … source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-nodeport/ Workload with NodePort Quick Start
  • 42. deploying a workload source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-ingress/
  • 43. Expose The Application Via An Ingress source : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/workload/quickstart-deploy-workload-ingress/
  • 44. Expose The Application Via An Ingress
  • 46. [controlPlane] Failed to bring up Control Plane: [Failed to create [kube-apiserver] container on host [10.0.2.15]: Failed to create Docker container [kube-apiserver] on host [10.0.2.15]: <nil>] 수동으로 관련 이미지 pull 하였을 경우(docker pull rancher/hyperkube:v1.17.0-rancher1), failed to register layer: Error processing tar file(exit status 1): write /opt/az/lib/python3.6/site- packages/azure/mgmt/web/models/__pycache__/certificate_details.cpython- 36.pyc: no space left on device 에러 발생하여, 아래 내용 수행하여 해결 docker system df If RECLAIMABLE amount is greater than zero (that would definitely the case) then run command docker system prune -a

Notes de l'éditeur

  1. id가 없는 이미지가 공식 이미지
  2. docker run = docker start + docker attach
  3. root@hwy:~# ll /var/lib/docker/overlay2/ root@hwy:~# touch abc.txt root@hwy:~# docker cp ./abc.txt ea19aba8d286 must specify at least one container source root@hwy:~# docker cp ./abc.txt ea19aba8d286:./ root@hwy:~# docker attach ea root@ea19aba8d286:/# ls a.txt abc.txt bin boot dev etc hello.txt home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@ea19aba8d286:/#
  4. --no-cache
  5. [daemon off 참고] https://roseline124.github.io/kuberdocker/2019/07/24/docker-study05.html
  6. https://darkrasid.github.io/docker/container/volume/2017/05/10/docker-volumes.html https://jungwoon.github.io/docker/2019/01/13/Docker-3/ docker run -itd -v /host/some/where:/container/some/where ubuntu
  7. root@hwy:~# docker exec -it sharp_ganguly bash docker logs –tail 10 –f dc7 docker system df If RECLAIMABLE amount is greater than zero (that would definitely the case) then run command docker system prune -a
  8. https://github.com/theAkito/rancher-helpers/blob/master/scripts/cleanup_rancher.sh