Friday, April 6, 2018

Katacoda docker interactive tutorial

Katacoda is the best thing I have seen this year. IT teachers and IT books are made obsolete by this tool.

https://www.katacoda.com/courses/docker/deploying-first-container

docker search redis

docker run -d redis

docker ps

docker inspect 654e238d3bef
docker logs 654e238d3bef

docker run -d --name redisHostPort -p 6379:6379 redis:latest

docker run -d --name redisDynamic -p 6379 redis:latest

docker port redisDynamic 6379

docker run -d --name redisMapped -v /opt/docker/data/redis:/data redis

docker run -d ubuntu ps
docker exec ubuntu bash

Dockerfile
FROM nginx:alpine
COPY . /usr/share/nginx/html

docker build -t webserver-image:v1 .

docker images

docker run -d -p 80:80 webserver-image:v1

curl docker
cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1       registry.test.training.katacoda.com
172.17.0.51     host01 751a165ea438 st_4yzuip_d2d
172.17.0.51     docker 751a165ea438 st_4yzuip_d2d
172.17.0.36     e1c00230b89e

to create data container:
docker create -v /config --name dataContainer busybox

docker cp config.conf dataContainer:/config/
docker run --volumes-from dataContainer ubuntu ls /config

to move the data container to another machine:
docker export dataContainer > dataContainer.tar
docker import dataContainer.tar



Networks

docker network create backend-network
docker run -d --name=redis --net=backend-network redis
docker run --net=backend-network alpine env
docker run --net=backend-network alpine cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0

docker run --net=backend-network alpine ping -c1 redis
docker network create frontend-network
docker network connect frontend-network redis
docker run -d -p 3000:3000 --net=frontend-network katacoda/redis-node-docker-example
curl docker:3000

docker network create frontend-network2
docker network connect --alias db frontend-network2 redis
docker run --net=frontend-network2 alpine ping -c1 db










No comments: