Docker

Courses

Course on LinuxAcademy Docker Deep Dive

Course Docker Deep Dive

Using the EC2 Container Service

EC2 Container Service

Useful resources

all the commands http://www.cloudkb.net/docker-commands-example/

Terminology

http://developerblog.redhat.com/2016/01/13/a-practical-introduction-to-docker-container-terminology/

link with the slides of the conference

http://www.slideshare.net/bobtfish

command line instructions

https://docs.docker.com/reference/commandline/cli/#commit

Installation

install on ubuntu 14.04

https://docs.docker.com/installation/ubuntulinux/#ubuntu-trusty-1404-lts-64-bit

Offline install on Red Had 6.5

source https://docs.docker.com/v1.5/installation/rhel/#red-hat-enterprise-linux-6.5-installation
You will need 64 bit RHEL 6.5 or later, with a RHEL 6 kernel version 2.6.32-431 or higher as this has specific kernel fixes to allow Docker to work.

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum install yum-plugin-downloadonly
yum install --downloadonly --downloaddir=. docker-io.x86_64
#move the file package-name.rpm in the machine with internet connection
yum install package-name.rpm

start and test
service docker start
chkconfig docker on

docker on Mac OS X

install and run kinematic

to enable bash to run

eval $(docker-machine env default)

to test run
docker info
Containers: 1
 Running: 0

nice guide with first steps on Mac OS X

http://www.alexecollins.com/first-steps-with-docker/

install brew http://brew.sh/ it is only 1 command

Useful commands

install the latest version of docker by script

curl -sSL https://get.docker.com/ubuntu/ | sudo sh
docker pull ubuntu:14.04
docker run --name demo -d ubuntu:14.04 /bin/bash -c "while true;do sleep 10;done"

list running containers

root@vagrant-ubuntu-trusty-64:~# docker ps

list running containers by id

root@vagrant-ubuntu-trusty-64:~# docker ps -q
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                                               NAMES
ffebef0e4f24        mysql/mysql-server   "/entrypoint.sh mysql"   4 minutes ago       Up 4 minutes

to stop the container use the container id
docker stop ffebef0e4f24

docker inspect demo

root@vagrant-ubuntu-trusty-64:~# docker inspect --format '{{.NetworkSettings.IPAddress}}' demo
172.17.0.2

docker run -t -e NAME="pEPPE" bootcamp:ex4 .

run mysql locally
MYSQL RUN

docker pull mysql
docker run --name MYSQL255 -P -e MYSQL_ROOT_PASSWORD=mysecretpassword mysql:5.5

log in inside

docker exec -it MYSQL255 /bin/bash
#and 
root@c2433ce1416e:/# mysql -u root -pmysecretpassword -h 0.0.0.0 -P 3306

install images offline

source http://serverfault.com/questions/701248/downloading-docker-image-for-transfer-to-non-internet-connected-machine

docker pull ubuntu
docker save -o ubuntu_image.docker ubuntu
#Transfer the file on the offline computer (USB/CD/whatever) and load the image from the file:
docker load < ubuntu_image.docker

check if the images was loaded

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
leanlabs/redis      latest              ff17d301e723        7 months ago        6.051 MB

run the container

run the server the first time

docker run -d -p 6379:6379 --name kanban_redis leanlabs/redis
db6d528742cb4627159b6089bc07baa09b64f5943dc43877a198bab01e65fba1
root@bsrpprd2018:~ # ps aux | grep docker
root      3935  0.0  0.1 522560 17596 pts/4    Sl   11:19   0:06 /usr/bin/docker -d
root     29837  0.2  0.0 198364  8680 pts/4    Sl   14:55   0:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6379 -container-ip 172.17.0.1 -container-port 6379
root     29920  0.0  0.0 103252   852 pts/4    S+   14:55   0:00 grep docker

run the service other times

docker start -a kaban_redis

delete all the images and containers

from the page http://stackoverflow.com/questions/21398087/how-to-delete-dockers-images

Delete all containers

docker rm $(docker ps -a -q)

Delete all images
docker rmi $(docker images -q)

Docker on Windows

put in debug mode

follow the instruction
https://docs.microsoft.com/en-us/virtualization/windowscontainers/troubleshooting#enabling-debug-logging
it is important that you run this command

sc.exe config docker binpath=
from the "command prompt" and not from power shell 

+++ Find Logs
as it is explained in the link 
https://docs.microsoft.com/en-us/virtualization/windowscontainers/troubleshooting#finding-logs
you can print the log 
[[code]]
Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-5) | Sort-Object Time 
[[/code]]
or save it in a file 
[[code]]
Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-30)  | Sort-Object Time | Export-CSV ~/last30minutes.CSV

for the AWS ECS service you can find the log in the windows EC2 machine at this path C:\ProgramData\Amazon\ECS\log

Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License