반응형

* 컨테이너 커밋은 기 Container 파일내에 변경 사항에 대한 내용을 image 화 하는 방식임.


1.  Docker 컨터이너 커밋
   - docker에서 작업한 컨테이너를 그대로 저장합니다.
     (별도로 기본 이미지에서 변경한 내역이 있을 때 사용)
   
   - docker commit [CONTAINER] [백업할 IMAGE_NAME]
   - 예)
   [root@localhost ~]# docker ps
CONTAINER ID        IMAGE                                                COMMAND                  CREATED             STATUS              PORTS                                                                           NAMES
2df5d23dbe0e        docker.test.io:8081/solution-was/2.1/x64:latest         "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        0.0.0.0:8888->8080/tcp                                                          docker_was_1
509d8e8f79c6        docker.test.io:8081/solution-dtg/2.1/x64:latest         "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        1337/tcp                                                                        docker_dtg_1
22bc42e1e8f7        docker.test.io:8081/solution-mhp/2.0/x64:latest         "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        1335/tcp, 1337/tcp, 1339-1341/tcp, 3882/tcp, 0.0.0.0:9900-9999->9900-9999/tcp   docker_mhp_1
dfce80fcd38f        docker.test.io:8081/solution-geoserver/2.2/x64:latest   "/bin/sh -c /run.sh"     4 months ago        Up 5 minutes        8080/tcp                                                                        docker_geoserver_1
eb18ba2b9010        postgres:10.5                                        "docker-entrypoint..."   4 months ago        Up 5 minutes        5432/tcp                                                                        docker_postgresdb_1
2c8ec75d22ed        cassandra:3.11.3                                     "docker-entrypoint..."   4 months ago        Up 5 minutes        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp                                     docker_cassandra_1
a427d7f36829        mongo:3.4                                            "docker-entrypoint..."   4 months ago        Up 5 minutes        0.0.0.0:27017->27017/tcp                                                        docker_mongodb_1

   위의 내용에서 docker_was_1 컨테이너를 commit할 예정
   
   [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              a85e7acc572a        6 months ago        1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB

  [root@localhost ~]# docker commit docker_was_1 docker.test.io:8081/solution-was/2.1/x64:latest
sha256:b4fd018ea938c46eae246ca8f6daa586c7216919b4be21a0e980bf05fca82dc0
[root@localhost ~]#

  위의 보이는 것처럼 b4fd018ea938c46eae246ca8f6daa586c7216919b4be21a0e980bf05fca82dc0 이름으로 이미지가 생성됩니다.
  
  [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        10 seconds ago      1.23 GB
docker.test.io:8081/solution-was/2.1/x64                       a85e7acc572a        6 months ago        1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB


  - 만든 이미지의 임의의 이름 부여
  [root@localhost ~]# docker tag docker.test.io:8081/solution-was/2.1/x64 mydocker_last

  - 내역 조회
  [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED              SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        About a minute ago   1.23 GB
mydocker_last                                 latest              b4fd018ea938        About a minute ago   1.23 GB
docker.test.io:8081/solution-was/2.1/x64                       a85e7acc572a        6 months ago         1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago         1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago         519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago         1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago         323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago         361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago         1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago         1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago         228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago        1.15 GB

     
 
2. docker 이미지 백업 및 배포

위에서 만든 mydocker_last 이미지를 백업 받습니다.

[root@localhost ~]# docker save -o mydocker_last_20190626.tar mydocker_last

[root@localhost ~]# ls -lsa mydocker*.tar
1229636 -rw------- 1 root root 1259146752 Jun 26 04:06 mydocker_last_20190626.tar


위의 생성된 내역을 기준으로

* 사전에 docker-compose로 전체를 내리고 수행 필요

a. docker rm [컨테이너 삭제]
b. docker rmi [이미지 삭제]

이미지 로드

[root@localhost ~]# docker load -i mydocker_last_20190626.tar
9186e1e3577e: Loading layer [==================================================>] 4.608 kB/4.608 kB
5e98fb5934af: Loading layer [==================================================>] 157.5 MB/157.5 MB
f33686d99dec: Loading layer [==================================================>] 2.048 kB/2.048 kB
f30a15d54bfb: Loading layer [==================================================>] 2.048 kB/2.048 kB
825ca8132690: Loading layer [==================================================>]  29.7 kB/29.7 kB
Loaded image: mydocker_last:latest
[root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
mydocker_last                                 latest              b4fd018ea938        12 minutes ago      1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB


기존 명칭으로 mydocker_last를 변경

 # docker tag mydocker_last docker.test.io:8081/solution-was/2.1/x64 
 
 [root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        13 minutes ago      1.23 GB
mydocker_last                                 latest              b4fd018ea938        13 minutes ago      1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB

복제된 기존 태그 삭제
[root@localhost ~]# docker rmi mydocker_last
Untagged: mydocker_last:latest
[root@localhost ~]# docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
docker.test.io:8081/solution-was/2.1/x64         latest              b4fd018ea938        14 minutes ago      1.23 GB
docker.io/solution/test-adp                      dev                 46312c34dd22        6 months ago        1.35 GB
docker.io/solution/test-dataengine               dev                 efa6b96652f1        7 months ago        519 MB
docker.test.io:8081/solution-mhp/2.0/x64         latest              f0589f2e98fa        7 months ago        1.3 GB
docker.io/cassandra                           3.11.3              8ea89760ce2b        7 months ago        323 MB
docker.io/mongo                               3.4                 9467ec7b04e5        7 months ago        361 MB
docker.test.io:8081/solution-dtg/2.1/x64         latest              6772091689dc        7 months ago        1.09 GB
docker.test.io:8081/solution-geoserver/2.2/x64   latest              7148066bbeba        7 months ago        1.4 GB
docker.io/postgres                            10.5                3fce051f5a48        8 months ago        228 MB
docker.io/solution/test-mariadb                  10.2                43eb83900c8a        15 months ago       1.15 GB

반응형

+ Recent posts