100 Days of Devops - Day 58-Docker Basics: Run Applications With Containers"
100 Days of Devops - Day 58-Docker Basics: Run Applications With Containers"
100 Days of Devops - Day 58-Docker Basics: Run Applications With Containers"
Docker Basics
Prashant LakheraFollow
Apr 10
Welcome to Day 58 of 100 Days of DevOps, Focus for today is
Docker Basics
What is a docker?
# yum check-update
Now run this command, this will install the latest version of
official docker repository
To verify it
# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
centos latest e934aafc2206 20
hours ago 199MB
To pull all the centos images(use -a options)
Now let’s take a look some more options available with docker
images(eg: if we are looking for long image id)
# docker images -a -q
e38bc07ac18e
e38bc07ac18e
e934aafc2206
805130e51ae9
As you can see in the below output they both are referring to
same image id
# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
centos latest
e934aafc2206 20 hours ago 199MB
localhost:5000/plakhera/centos latest
e934aafc2206 20 hours ago 199MB
To verify it
# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
centos latest
e934aafc2206 20 hours ago 199MB
localhost:5000/plakhera/centos latest
e934aafc2206 20 hours ago 199MB
Command to run the container
* File system
* Process table
* Network Interfaces
# docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
bed3f29d8652 centos "/bin/bash" 4
minutes ago Up 4 minutes
romantic_banach
# docker ps -a
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
bed3f29d8652 centos "/bin/bash" 5
minutes ago Exited (0) 6 seconds ago
romantic_banach
OR
But as you can see you are only getting value out of it, but we
need in the form of key-value pair
# docker images
REPOSITORY TAG IMAGE ID
CREATED SIZE
hello-world v1 e38bc07ac18e 5
days ago 1.85kB
hello-world v2 e38bc07ac18e 5
days ago 1.85kB
$ docker ps -a -q |head
ed84dd07b639
16b63895a6c3
6be3b83f6dc3
41c08f6cf45d
where
$ docker rm 16b63895a6c3
16b63895a6c3
Now let’s remove the original image and try to load it back on
the system OR we can copy this tar file to other machines, and
t load this image
# docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 18.04.0-ce
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries
splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-693.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.4MiB
Name: docker.example.com
ID: JLNP:OVGZ:4LFR:W2IQ:V3XB:JV7G:X7HE:ZFAD:2VFE:WENX:KKGX:IJBM
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
# docker version
Client:
Version: 18.04.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:21:36 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.04.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:25:25 2018
OS/Arch: linux/amd64
Experimental: false
To get information about the container in top style output
# docker events
2018-04-13T10:17:55.692534036-04:00 container die
662891f10a6d4f77f519ad0db4ee0d441940d0f7fb037d904446f7764dd40451
(exitCode=0, image=centos:latest, name=jolly_meninsky,
org.label-schema.schema-version== 1.0 org.label-
schema.name=CentOS Base Image org.label-schema.vendor=CentOS
org.label-schema.license=GPLv2 org.label-schema.build-
date=20180402)
2018-04-13T10:17:55.721338352-04:00 network disconnect
695787e430858c26d10e0e0980f77aff4b1a5507a3266b19f283036e3b9b34b5
(container=662891f10a6d4f77f519ad0db4ee0d441940d0f7fb037d904446f
7764dd40451, name=bridge, type=bridge)
# To get image id
$ docker images -a -q
5b38599a96be
6662d8cc2447
bb15b898ca55
6601d6761139
8bd1c9f6dd75
dd464784a563
4c277e38e2bd
To get container id
$ docker ps -a -q
f9c2e5959bc5
Privileged Containers
Now the biggest issue with this we can even kill any process
running on the host
Reference