'docker vs vm'에 해당되는 글 1건

  1. 2017.06.10 Docker 기초 - 1

Docker 기초 - 1

개발 2017. 6. 10. 22:57

Docker


참고

  1. docker 란

    • 애플리케이션을 신속하게 구축, 테스트 및 배포할 수 있는 소프트웨어 플랫폼
    • 소프트웨어를 컨테이너라는 표준화된 유닛으로 패키징하며, 이 컨테이너에는 라이브러리, 시스템 도구, 코드, 런타임 등 소프트웨어를 실행하는 데 필요한 모든 것이 포함되어 있다
    • Virtaul Machine vs Container
      • 컨테이너는 별도의 OS나 드라이버 없이 Host OS를 공유하는 형태로 실행 VM 의 경우 많은 시스템 리소스를 사용하게 된다
      • VM 은 서버, Host OS, Hypervisor 위에 올라가게 되고, 각 VM은 OS, 드라이버, 메모리 등 컴퓨터 환경이 구성되기 위해 필요한 요소들을 갖추게 된다
      • Container 의 문제점
        • Security
          • Libcontainers accesses five namespaces — Process, Network, Mount, Hostname, and Shared Memory — to work with Linux
  2. ubuntu 환경에서 docker 설치하기

    • Set up the repository
        $ sudo apt-get -y install apt-transport-https  ca-certificates curl
        $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
        OK
        $ sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
        $ sudo apt-get update
        $ sudo apt-cache policy docker-engine
      
    • Get Docker
        $ sudo apt-get -y install docker-engine
      
  3. docker 명령어 사용하기

    • docker [option] [command] [arguments]
  4. docker 환경에서 tomcat server 설치 및 배포하기

    • tomcat image 확인
        docker@DockerClient:~$ docker search tomcat
        NAME                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
        tomcat                         Apache Tomcat is an open source implementa...   1346      [OK]
        dordoka/tomcat                 Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 ba...   37                   [OK]
        davidcaste/alpine-tomcat       Apache Tomcat 7/8 using Oracle Java 7/8 wi...   18                   [OK]
        cloudesire/tomcat              Tomcat server, 6/7/8                            15                   [OK]
        andreptb/tomcat                Debian Jessie based image with Apache Tomc...   7                    [OK]
        openweb/oracle-tomcat          A fork off of Official tomcat image with O...   5                    [OK]
        fbrx/tomcat                    Minimal Tomcat image based on Alpine Linux      4                    [OK]
        bitnami/tomcat                 Bitnami Tomcat Docker Image                     2                    [OK]
        abzcoding/tomcat-redis         a tomcat container with redis as session m...   2                    [OK]
        picoded/tomcat                 tomcat 8 with java 8, and MANAGER_USER / M...   2                    [OK]
        antoineco/tomcat-mod_cluster   Apache Tomcat with JBoss mod_cluster            1                    [OK]
        camptocamp/tomcat-logback      Docker image for tomcat with logback integ...   1
      
    • docker image 저장
        docker@DockerClient:~$ docker image pull davidcaste/alpine-tomcat
      
    • docker image 저장 위치 확인

        root@DockerClient:/var/lib/docker/image/aufs# ls
        distribution  imagedb  layerdb  repositories.json
      
        root@DockerClient:/var/lib/docker/image/aufs# cat repositories.json
        {"Repositories":{"davidcaste/alpine-tomcat":{"davidcaste/alpine-tomcat:latest":"sha256:068917e56bf36062d3bfd6fe728b55b01b5ebd17406fda27cb2dca07acbfbfde","davidcaste/alpine-tomcat@sha256:5c9e43e76d66fc147bff8a9328d8369cb0d21505a5d0e055a24764cb39c439a0":"sha256:068917e56bf36062d3bfd6fe728b55b01b5ebd17406fda27cb2dca07acbfbfde"},"hello-world":{"hello-world:latest":"sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233","hello-world@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7":"sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233"}}}
      
        root@DockerClient:/var/lib/docker/image/aufs/imagedb/content/sha256# ls -al
        total 24
        drwx------ 2 root root 4096 Jun  7 08:37 .
        drwx------ 3 root root 4096 May 24 16:58 ..
        -rw------- 1 root root 8648 Jun  7 08:37 068917e56bf36062d3bfd6fe728b55b01b5ebd17406fda27cb2dca07acbfbfde
        -rw------- 1 root root 1478 May 24 17:21 48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233
      
    • docker 실행
        docker@DockerClient:~$ docker run -it --rm davidcaste/alpine-tomcat /opt/tomcat/bin/catalina.sh run
        Using CATALINA_BASE:   /opt/tomcat
        Using CATALINA_HOME:   /opt/tomcat
        Using CATALINA_TMPDIR: /opt/tomcat/temp
        Using JRE_HOME:        /opt/jdk
        Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
      
    • docker 실행 확인

        docker@DockerClient:~$ docker ps
        CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS               NAMES
        381a87f75c84        davidcaste/alpine-tomcat   "/opt/tomcat/bin/c..."   4 minutes ago       Up 4 minutes        8080/tcp            inspiring_colden
        docker@DockerClient:~$ docker exec 381a87f75c84 ifconfig
        eth0      Link encap:Ethernet  HWaddr 02:42:AC:11:00:02
                  inet addr:172.17.0.2  Bcast:0.0.0.0  Mask:255.255.0.0
                  inet6 addr: fe80::42:acff:fe11:2%32650/64 Scope:Link
                  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                  RX packets:15 errors:0 dropped:0 overruns:0 frame:0
                  TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
                  collisions:0 txqueuelen:0
                  RX bytes:1075 (1.0 KiB)  TX bytes:1176 (1.1 KiB)
      
        lo        Link encap:Local Loopback
                  inet addr:127.0.0.1  Mask:255.0.0.0
                  inet6 addr: ::1%32650/128 Scope:Host
                  UP LOOPBACK RUNNING  MTU:65536  Metric:1
                  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
                  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
                  collisions:0 txqueuelen:1
                  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
      
        docker@DockerClient:~$ telnet 172.17.0.2 8080
        Trying 172.17.0.2...
        Connected to 172.17.0.2.
        Escape character is '^]'.


'개발' 카테고리의 다른 글

React 의 특징  (0) 2017.12.20
Git 입문  (0) 2017.12.17
go 언어 사용하기  (0) 2016.12.02
swagger 사용하기  (0) 2016.11.15
iOS custom framework 만들기  (0) 2016.11.04
Posted by 감각적신사
,