DOCKER COMMAND
- builder
- config
- container
ls list containers - docker container ls
run: run a command in a new container - docker container run <image_name> OR docker
container run -P -d <image_name> (-P assigns random port number -d runs in the
background)
inspect: Display detailed information o one or more containers - dokcer container
inspect <container_id>
top: Display the running processes of a container - docker container top
<container_id>
restart: Restart one or more containers
attach: Attach a local standard input, output, and error streams to a running
container to run commands - docker container attach <container_id>
pause: pause a running container - docker container pause <container_id>
unpause: unpases a paused container - dokcer container unpause <container_id>
start: starts an stoped container: docker container start <container_id>
exec: allows to execute commands in a docker container - docker container exec -it
<container_id> <command> - docker exec -it 34r343f4 /bin/bash OR docker exec -it
34r343f4v ls /usr/share/nginx/hmtl
logs: shows logs of a running container: docker container logs <container_id>
stats: shows resources usage of a container - docker container stats <container_id>
- Engine
- image
ls: show images- docker image ls
pull: pull images from docker hub - docker image pull <image name:tag>
push: push an image or repository to a registry -
inspect: Return low level information on Docker objects - docker image inspect
<image_id>
import: import the contents from a tarball to create a filesystem image
- network
- node
- plugin
- secret
- service
- stack
- swarm
- system
- trust
- volume
- rm: allow to remove images and containers: docker container rm <container_id>,
docker image rm <image_id>
PORTS
-Expose
--expose: this flag helps and exports a port: docker container run --expose
<port_number> <image>
- Publish
Maps a container port to a host's port
-p --publish: used to list a published container's port to the host
-P --publish-all: Used to publish all exposed ports to random ports
DOCKER LOGS
show information logged by a runnign container: docker container logs
<container_id>
show information logged by all containers participating in a service: docker
service logs <service_id>
Logs need to be output to STDOUT and STDERR
Nginx example:
RUN ln -sf /dev/stdout /var/log(nginx/access.log && ln -sf
/dev/stderr/var/log/nginx/error.log
DOCKER NETWORKING
There are three components
- Container Network model (CNM)
- The libnetwork implements CNM, this is used for connecting containers and service
discovery, load balancing, etc.
- Driver extended the model by network topologies
Network drivers:
- bridge, default network
- host
- overlay
- macvlan
- none
- Network plugins from third parties
Three building blocks:
- Sandbox: isolates the network stack
- Endpoint: virtual network interfaces, connects sandbox to networks
DOCKER NETWORK COMMANDS:
docker network ls: list all network created in docker
docker network inspect: get infromation of the network: docker network inspect
<network_id>
create network: docker network create <name>
connect network to container: docker network connect <network_name>
<container_name/id>
disconnect network to container: docker network disconnect <network_name>
<container_name/id>
create network with subnet and gateway: docker network create --subnet <range> --
gateway <range> <network name>
create network with ip ranges and specific drivers: docker network create --subnet
<range> --gateway <range> --ip-range=<iprange> --driver=<driver_type> --
label=<label> <network_name>
docker network create --subnet 10.1.0.0/16 --gateway 10.1.0.1 --ip-
range=10.1.4.0/24 --driver=bridge --label=host4nwtwork network_test
connect network when creating container: docker container run --name
<container_name> --network <network_name> <docker_image>
docker container run --name container-test --network network-name-1 centos
docker contianer run -d --name <network_name> --ip <ip_address> --network
<network_id/name> <docker_image>
docker container run -d --name network-test02 --ip 10.1.4.102 --network br02
nginx
DOCKER VOLUMES
Bind Mount: they have limited functionality compared to volumes, with bind mount a
file or directory on the host machine is mounted into a container
Volumes: use a new directory that is created within docker's storage directory on
the host machine and Docker manages that directory's contents
4152 3137 2968 8957
sergio delgado
INSTALL HELM