티스토리 뷰

Docker 환경 구성하기

Homebrew로 Docker를 설치해봅시다.

$ brew install docker

그리고 Host OS와 커뮤니케이션 할 인터페이스인 Docker-machine을 설치합니다.

$ brew install docker-machine

Docker-machine 만들기

Docker-machine을 올리기 위해서 virtualbox를 설치합니다.

$ brew cask install virtualbox

Docker-machine을 만들어 봅시다.

$ docker-machine create --driver virtualbox defaul

제대로 생성 되었는지 확인해 볼까요?

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER    ERRORS
default   -        virtualbox   Stopped                 Unknown   

Docker-machine을 실행시키고 활성화 시킵니다.

$ docker-machine start default
$ docker-machine env default
$ eval $(docker-machine env default)

Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/choeseonghui/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval $(docker-machine env default)

활성화 되었는지 확인해 볼까요?

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v17.03.0-ce   

ACTIVE의 *이 활성화 표시입니다.

Docker 컨테이너 생성하기

NodeJS 컨테이너를 생성하고 버전을 확인해 볼까요?

$ docker run -ti --name mycontainer node /bin/bash

Unable to find image 'node:latest' locally
latest: Pulling from library/node
6d827a3ef358: Pull complete 
2726297beaf1: Pull complete 
7d27bd3d7fec: Pull complete 
44ae682c18a3: Pull complete 
e8c647cd1137: Pull complete 
026a2f399da4: Pull complete 
c3af0fce5111: Pull complete 
ef826cc54042: Pull complete 
Digest: sha256:a72f8cd9aba12ea3a19ada91e077c4d8822d3bd7dc3c4707b16630e5c2477845
Status: Downloaded newer image for node:latest
root@d3652e91ed63:/# node --version
v7.8.0


By Hui


댓글
댓글쓰기 폼