Friday, August 04, 2017

Docker


Installation

https://docs.docker.com/engine/getstarted/step_one/

Examples

Run nginx container
docker run -d -p 80:80 --name webserver nginx
You should be able to access it by going to http://localhost
List all docker images
docker images
List running containers
docker ps
Copy file to a docker container
docker cp html.tar 213389b682d6:/tmp/
Connect to a running container
docker exec -it 213389b682d6 /bin/bash
Saving new container after the changes
docker commit -m "Adding ops runbook" -a "Igor" 213389b682d6 runbook
Run your new container
docker run -d -p 80:80 -it runbook /bin/bash
Login to the container shell
docker exec -it 7e7d9c35a216 bash
Exit from the container shell
Ctrl + p , Ctrl + q
Restart nginx inside your container
docker exec -it 213389b682d6 /etc/init.d/nginx restart
After docker service restart - make sure ecs-agent is running
root@ecs00-us-west-2b:~# docker start ecs-agent

Logging

It seems like docker puts logs in two places:
  1.  Actual container logs
    /var/lib/docker/containers
  2. docker system log
    /var/log/docker.log
The following options should take care of log rotation:
/etc/default/docker
DOCKER_OPTS="--pidfile=/var/run/docker.pid --log-level=warning --log-opt max-size=1g --storage-driver=zfs --storage-opt=zfs.fsname=zd0/containers"
log-level makes docker.log file less verbose.  log-opt makes container logs no bigger than 1GB

No comments: