AWSKRUG 변규현
2017.06.08
Docker is the world’s leading software container platform. Developers use Docker to eliminate “works on my machine” problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density. Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely and with confidence for both Linux and Windows Server apps.
Using containers, everything required to make a piece of software run is packaged into isolated containers. Unlike VMs, containers do not bundle a full operating system - only libraries and settings required to make the software work are needed. This makes for efficient, lightweight, self-contained systems and guarantees that software will always run the same, regardless of where it’s deployed.
A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.
# docker hub에서 이미지 가져오기
$ docker pull ubuntu
# ubuntu image를 데몬으로 실행하기
$ docker run -dit --name myUbuntu ubuntu
# novemberde/node-pm2를 base image로 하는 docker container 실행하기
$ docker run -it -p 8080:3000 -v /home/docker/docker_node_server:/src \
--name docker_node_server novemberde/node-pm2
# daemon으로 실행하기
$ docker run -dit -p 8080:3000 -v /home/docker/docker_node_server:/src \
--name docker_node_server novemberde/node-pm2
# 실행하고 있는 docker container 확인하기
$ docker ps
# docker container 설정 사항 확인하기
$ docker inspect docker_node_server
# 모든 docker container 확인하기
$ docker ps -a
# 컨테이너 삭제하기
$ docker rm docker_node_server
FROM novemberde/node-pm2
MAINTAINER KH BYUN "novemberde.github.io"
# RUN npm install -g pm2 node-gyp
ENV NODE_ENV production
EXPOSE 3000
COPY ./ /src
RUN npm install --prefix /docker_node_server
CMD ["pm2-docker", "/src/app.js"]
api:
build: ./
ports:
- "80:3000"
log_opt:
max-size: 40m
# docker-compose를 사용할 경우
api:
image: novemberde/docker_node_server
ports:
- "80:3000"
log_opt:
max-size: 40m
# docker-cli 명령어로 사용할 경우
docker run -dit --name docker_node_server -p 80:3000 novemberde/docker_node_server
1. 배포환경과 테스트 환경을 분리하자.
근데 중복된 아키텍쳐를 사용하면 돈이 줄줄 새지 않나?
2. ElasticCache의 Cache를 갱신하고 싶은데 어떡하지?
3. 특정 서버가 실행될 때 사용되는 명령어를 모아둔다.