Skip to content

Commit 6129993

Browse files
committed
updated docker
1 parent 073b0c6 commit 6129993

13 files changed

+192
-16
lines changed

docker/Install-Docker-manual.txt

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
1-
Install Docker Ubuntu
2-
=======================
1+
Install Docker on Ubuntu:
32

4-
sudo apt-get remove docker docker-engine docker.io containerd runc
5-
sudo apt-get update
6-
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
3+
sudo apt-get remove docker docker-engine docker.io containerd runc
4+
sudo apt-get update
5+
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
6+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
7+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
8+
sudo apt-get update
9+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
710

8-
## Add Dockers official GPG key
9-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
10-
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
11-
sudo apt-get update
12-
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
11+
Add your user to the docker group, giving the user permission to run docker commands:
12+
sudo usermod -aG docker cloud_user
1313

14-
below is just FYI to know all available docker stable versions
15-
## Check Available Version for Install"
14+
Test the installation by running a simple container:
15+
docker run hello-world
16+
17+
## FYI Only ## Check Available Version for Install"
1618
apt-cache madison docker-ce | awk '{print $3}'
1719

1820

1921
=========================================================================
22+
23+
Install Docker on CentOS:
24+
25+
sudo yum install -y device-mapper-persistent-data lvm2
26+
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
27+
sudo yum install -y docker-ce docker-ce-cli containerd.io
28+
sudo systemctl start docker
29+
sudo systemctl enable docker
30+
31+
Add your user to the docker group, giving the user permission to run docker commands:
32+
sudo usermod -aG docker cloud_user
33+
34+
Test the installation by running a simple container:
35+
docker run hello-world
36+
37+
===========================================================================
38+
39+
2040
Install docker-compose
2141

2242
sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

docker/containers/readme.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,23 @@ how to access the applications running inside the container from external world
5959

6060
Advanced Container commands
6161

62+
limit container resources
63+
docker run -d --restart unless-stopped -p 8080:80 --memory 500M --memory-reservation 256M nginx
64+
docker run -d -P --cpus=".5" nginx
65+
66+
Run a docker container, overriding the system default logging driver settings:
67+
docker run --log-driver json-file --log-opt max-size=50m nginx
68+
6269
updating container network
63-
docker network disconnect bridge 209c1cdcb10e
64-
docker network connect myb 209c1cdcb10e
70+
docker network disconnect bridge <contid>
71+
docker network connect myb <contid>
6572

6673
docker run -itd --net net1 alpine
67-
docker network connect net2 contid ( container will be present in both net1 & net2 networks )
74+
docker network connect net2 contid
75+
( container will be present in both net1 & net2 networks )
76+
77+
--restart flag: specify when the container should be automatically restarted
78+
1) no(default): Never restart the container
79+
2) on-failure: only if the container fails (exits with non-zero exit code)
80+
3) always: Always restart the container whether it succeeds or fails. Also start the container automatically on daemon startup
81+
4) unless-stopped: Always restart the container whether it succeeds or fails, and the daemon startup, unless the container was manually stopeed

docker/daemon/.namespaces.txt.swp

12 KB
Binary file not shown.

docker/daemon/cgroups.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Docker Engine on Linux also relies on another technology called control groups (cgroups).
2+
A cgroup limits an application to a specific set of resources.
3+
Control groups allow Docker Engine to share available hardware resources to containers and optionally enforce limits and constraints.
4+
For example, you can limit the memory available to a specific container.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Set the default logging driver
2+
==========================================
3+
4+
sudo vi /etc/docker/daemon.json
5+
{
6+
"log-driver": "syslog"
7+
}
8+
9+
OR
10+
11+
{
12+
"log-driver": "json-file",
13+
"log-opts": {
14+
"max-size": "15m"
15+
}
16+
}
17+
18+
sudo systemctl restart docker
19+
docker info | grep Logging
20+
21+
more info: https://docs.docker.com/config/containers/logging/syslog/
22+
23+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Get the current storage driver:
2+
docker info
3+
4+
Two ways we can set the storage drivers
5+
6+
1) Set the storage driver explicitly by providing a flag to the Docker daemon:
7+
sudo vi /usr/lib/systemd/system/docker.service
8+
Edit the ExecStart line, adding the --storage-driver devicemapper flag:
9+
ExecStart=/usr/bin/dockerd --storage-driver devicemapper ...
10+
After any edits to the unit file, reload Systemd and restart Docker:
11+
12+
sudo systemctl daemon-reload
13+
sudo systemctl restart docker
14+
15+
16+
2) We can also set the storage driver explicitly using the daemon configuration file.
17+
This is the method that Docker recommends.
18+
Note that we cannot do this and pass the --storage-driver flag to the daemon at the same time
19+
20+
sudo vi /etc/docker/daemon.json
21+
Set the storage driver in the daemon configuration file:
22+
23+
{
24+
"storage-driver": "devicemapper"
25+
}
26+
Restart Docker after editing the file.
27+
It is also a good idea to make sure Docker is running properly after changing the configuration file:
28+
29+
sudo systemctl restart docker
30+
sudo systemctl status docker
31+
32+
more Info: https://docs.docker.com/storage/storagedriver/select-storage-driver/

docker/daemon/enable-daemon-dubug.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enable dubug
2+
=============
3+
4+
vi /etc/docker/daemon.json
5+
6+
{
7+
"debug": true
8+
}

docker/daemon/namespaces.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Namesapces are a linux technology that allows processes to be isolated in terms of the resources that they see. They can be used to prevent different processes from interfering or interacting with one another.
2+
3+
Docker uses namespaces to isolate containers. This technology allows containers to operate independently and securely.
4+
5+
Docker Engine uses namespaces such as the following on Linux:
6+
7+
pid namespace: Process isolation (PID: Process ID).
8+
net namespace: Managing network interfaces (NET: Networking).
9+
ipc namespace: Managing access to IPC resources (IPC: InterProcess Communication).
10+
mnt namespace: Managing filesystem mount points (MNT: Mount).
11+
uts namespace: Isolating kernel and version identifiers. (UTS: Unix Timesharing System).
12+
User namespaces: requires special configuration. Allows container processes to run as root inside the container while mapping that user to an unprivileged user on the host.

docker/daemon/readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ Docker Client:
1717

1818

1919
![Docker Architecturre](DockerArchitecture.png?style=centerme)
20+
21+
22+
Container Format:
23+
=================
24+
25+
Docker Engine combines the namespaces, control groups, and UnionFS into a wrapper called a container format.
26+
The default container format is libcontainer.
27+
In the future, Docker may support other container formats by integrating with technologies such as BSD Jails or Solaris Zones
28+

docker/daemon/unionFS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Union file systems, or UnionFS, are file systems that operate by creating layers, making them very lightweight and fast.
2+
Docker Engine uses UnionFS to provide the building blocks for containers.
3+
Docker Engine can use multiple UnionFS variants, including AUFS, btrfs, vfs, and DeviceMapper.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
what is Dockefile:
2+
==================
3+
A Dockerfile is set of instructions which are used to construct a Docker Image.
4+
These instructions are called directives.
5+
6+
Dockerfiel directive:
7+
=====================
8+
9+
FROM: start a new build stage and sets the base image. usually must be the first directive in the Dockerfile (except ARG can be placed before FROM).
10+
11+
ENV: set environment variables. These can be refefenced in the Dockerfile itself and are visible to the container at runtime.
12+
13+
RUN: creates a new layer on top of the previous layer by running a command inside that new layer and commiting the changes.
14+
15+
CMD: specify a default command used to run a container at execution time.
16+
17+
EXPOSE: documents which port(s) are intended to published when running a container
18+
19+
WORKDIR: sets the current working directory for subsequent directives such as ADD, COPY, CMD, ENTRYPOINT, etc. Cna be used multiple time to change the directories throught the Dockerfile. you can also use relative path, which sets the new working direcotry relative to the previous working direcotry.
20+
21+
COPY: copy files from the local machine to the image.
22+
23+
ADD: similar to COPY, but can also pull files using a URL and extract an archive into loose files in the image.
24+
25+
STOPSIGNAL: specify the signal that will be used to stop the container.
26+
27+
HEALTHCHECK: speciry a command to run in order to perform a custom health check to verify that the container is working properly.

docker/images/readme.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
what are Docker Images:
2+
=======================
3+
An image is a package that consists of an application and all of its dependencies to run the application in a container.
4+
containers and images use a layered file system. Each layer consists only the differences from the previous layer.
5+
the image consists of one or more read only layers, while container adds on one writable layer on top of image layers.
6+
7+
8+
The layered file system allows multiple images and containers to share the same layers.
9+
this would result in:
10+
smaller overall storage footprint
11+
faster image transfer
12+
faster image build
13+
114
how to build docker image
215
=========================
3-
two ways
16+
two ways
417
1) MANAUL
518
2) AUTOMATED
619

docker/swarm/backup-restore-swarm.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Create the Backup On the manager:
2+
sudo systemctl stop docker
3+
sudo tar -zvcf backup.tar.gz -C /var/lib/docker/swarm
4+
sudo systemctl start docker
5+
6+
Restore from Backup On the manager:
7+
sudo systemctl stop docker
8+
sudo rm -rf /var/lib/docker/swarm/*
9+
sudo tar -zxvf backup.tar.gz -C /var/lib/docker/swarm/
10+
sudo systemctl start docker
11+
docker node ls

0 commit comments

Comments
 (0)