how to docker install

Install docker in CLI

  1. Install Homebrew

    1
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install docker toolbox

    1
    2
    brew cask install docker-toolbox
    brew install caskroom/cask/brew-cask

How to Start docker

  1. check the docker version

    1
    docker version
  2. list the docker machine

    1
    docker-machine ls
  3. create the docker machine

    1
    docker-machine create --driver "virtualbox" myBoxName
  4. start the docker machine

    1
    docker-machine start myBoxName
  5. get into the env of the docker machine

    1
    eval $(docker-machine env myBoxName)
    1
    2
    3
    4
    5
    6
    export DOCKER_TLS_VERIFY="1"
    export DOCKER_HOST="tcp://192.168.99.100:2376"
    export DOCKER_CERT_PATH="/Users/huklee/.docker/machine/machines/myBoxName"
    export DOCKER_MACHINE_NAME="myBoxName"
    # Run this command to configure your shell:
    # eval $(docker-machine env myBoxName)
  6. when the certification is not working

    1
    docker-machine regenerate-certs myBoxName

Start the docker image on the docker box

  1. see the docker image list

    1
    docker images
  2. search the docker images on web

    1
    2
    docker search [image]
    # ex) docker search centos
  3. download the docker image

    1
    docker pull centos:latest
  4. the simple test of docker

    1
    2
    3
    4
    5
    6
    docker run hello-world
    docker run -d -i -t --name "test2" ubuntu /bin/bash # -d : background
    docker run -it --name "test1" centos /bin/cal
    docker ps
  5. attach the docker process

    1
    docker attach hello
    • to exit without stop :

docker daemon이 꺼져 있는 경우 / docker server is off

  • Mac에서는 일단 docker Quickstart Terminal을 찾아서 키면 자동으로 docker daemon default 세팅이 된다.
  • 이후에 아래 명령을 실행해 주면 된다.

    1. start the docker machine

      1
      docker-machine start myBoxName
    2. get into the env of the docker machine

      1
      eval $(docker-machine env myBoxName)

궁금한 점들

  • docker를 사용해서 ubuntu / centos 등을 실행시키면 실제 파일 저장 경로라던가 하는 것들은 어떻게 되는 것인지?
  • 왜 sudo 를 사용하면 docker-toolbox를 사용했을 때, 에러가 나는가.
  • 왜 그렇게 ubuntu같은 것들도 용량이 무지하게 작은가?
  • file system을 공유해서 실제 file directory처럼 사용하는 것이 가능한가?

Docker 데이터 볼륨 사용하기

install docker with homebrew on Mac

docker 개념잡기 : 아키텍쳐

Share Comments