Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docker_basic_configuration [2020/01/23 12:30] – andonovj | docker_basic_configuration [2020/01/25 04:02] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Overview====== | + | =====Overview====== |
Docker configuration is done in the YML files, where we should describe what we want and how that should be linked in regards to: | Docker configuration is done in the YML files, where we should describe what we want and how that should be linked in regards to: | ||
Line 7: | Line 7: | ||
+ | =====Installation===== | ||
+ | Docker is open source application and can be freely downloaded and installed. | ||
+ | Now it is important to notice that, in general docker installed on Windows will run windows apps and docker installed on Linux will run Linux apps. | ||
+ | Of course, there are exception of that rule and Linux docker can run Windows apps, but that is story for another time. | ||
+ | Docker is easily installed as follows: | ||
+ | ====Install the package==== | ||
+ | You can install the package using your favorite package manager, in my case " | ||
+ | <sxh bash> | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | [dockerrepo] | ||
+ | name=Docker Repository | ||
+ | baseurl=https:// | ||
+ | enabled=1 | ||
+ | gpgcheck=1 | ||
+ | gpgkey=https:// | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | [root@postgresqlpgpool app]# yum install docker-ce docker-ce-cli containerd.io | ||
+ | Loaded plugins: fastestmirror, | ||
+ | Loading mirror speeds from cached hostfile | ||
+ | * base: ftp.cvut.cz | ||
+ | * extras: ftp.cvut.cz | ||
+ | * updates: ftp.cvut.cz | ||
+ | Resolving Dependencies | ||
+ | --> Running transaction check | ||
+ | ---> Package containerd.io.x86_64 0: | ||
+ | ---> Package docker-ce.x86_64 3: | ||
+ | ---> Package docker-ce-cli.x86_64 1: | ||
+ | --> Finished Dependency Resolution | ||
+ | |||
+ | Dependencies Resolved | ||
+ | |||
+ | =========================================================================================================================================================================================================================== | ||
+ | | ||
+ | =========================================================================================================================================================================================================================== | ||
+ | Installing: | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Transaction Summary | ||
+ | =========================================================================================================================================================================================================================== | ||
+ | Install | ||
+ | |||
+ | Total size: 87 M | ||
+ | Installed size: 362 M | ||
+ | Is this ok [y/d/N]: y | ||
+ | Downloading packages: | ||
+ | Running transaction check | ||
+ | Running transaction test | ||
+ | Transaction test succeeded | ||
+ | Running transaction | ||
+ | Installing : 1: | ||
+ | Installing : containerd.io-1.2.10-3.2.el7.x86_64 | ||
+ | Installing : 3: | ||
+ | Verifying | ||
+ | Verifying | ||
+ | Verifying | ||
+ | |||
+ | Installed: | ||
+ | containerd.io.x86_64 0: | ||
+ | |||
+ | Complete! | ||
+ | [root@postgresqlpgpool app]# service docker start | ||
+ | Redirecting to / | ||
+ | [root@postgresqlpgpool app] | ||
+ | </ | ||
+ | |||
+ | ====Start the service==== | ||
+ | <sxh bash> | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | Redirecting to / | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | Redirecting to / | ||
+ | ● docker.service - Docker Application Container Engine | ||
+ | | ||
+ | | ||
+ | Docs: https:// | ||
+ | Main PID: 3890 (dockerd) | ||
+ | Tasks: 19 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Jan 23 07:36:42 postgresqlmaster systemd[1]: Starting Docker Application Container Engine... | ||
+ | Jan 23 07:36:42 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster dockerd[3890]: | ||
+ | Jan 23 07:36:43 postgresqlmaster systemd[1]: Started Docker Application Container Engine. | ||
+ | Hint: Some lines were ellipsized, use -l to show in full. | ||
+ | </ | ||
+ | |||
+ | ====Run "Hello World" | ||
+ | <sxh bash> | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | 1b930d010525: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for hello-world: | ||
+ | |||
+ | Hello from Docker! | ||
+ | This message shows that your installation appears to be working correctly. | ||
+ | |||
+ | To generate this message, Docker took the following steps: | ||
+ | 1. The Docker client contacted the Docker daemon. | ||
+ | 2. The Docker daemon pulled the " | ||
+ | (amd64) | ||
+ | 3. The Docker daemon created a new container from that image which runs the | ||
+ | executable that produces the output you are currently reading. | ||
+ | 4. The Docker daemon streamed that output to the Docker client, which sent it | ||
+ | to your terminal. | ||
+ | |||
+ | To try something more ambitious, you can run an Ubuntu container with: | ||
+ | $ docker run -it ubuntu bash | ||
+ | |||
+ | Share images, automate workflows, and more with a free Docker ID: | ||
+ | | ||
+ | |||
+ | For more examples and ideas, visit: | ||
+ | | ||
+ | |||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | |||
+ | |||
+ | </ | ||
=====Configurations===== | =====Configurations===== | ||
With docker we can download and run any image from a registry. Currently there are over 3 million dockerized applications including: | With docker we can download and run any image from a registry. Currently there are over 3 million dockerized applications including: | ||
Line 19: | Line 150: | ||
Let's start by downloading and installing MySQL database which has been dockerized. | Let's start by downloading and installing MySQL database which has been dockerized. | ||
- | ====MySQL | + | ====MySQL |
Once we have docker installed, we can search and install any image we want: | Once we have docker installed, we can search and install any image we want: | ||
Line 69: | Line 200: | ||
</ | </ | ||
- | By default the " | + | ===Install MySQL=== |
- | + | Now we can install the mysql image using the following commands: | |
- | <sxh bash> | + | |
- | [root@localhost ~]# docker run hello-world | + | |
- | Unable to find image ' | + | |
- | latest: Pulling from library/ | + | |
- | 9db2ca6ccae0: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for hello-world: | + | |
- | + | ||
- | Hello from Docker! | + | |
- | This message shows that your installation appears to be working correctly. | + | |
- | + | ||
- | To generate this message, Docker took the following steps: | + | |
- | 1. The Docker client contacted the Docker daemon. | + | |
- | 2. The Docker daemon pulled the " | + | |
- | (amd64) | + | |
- | 3. The Docker daemon created a new container from that image which runs the | + | |
- | executable that produces the output you are currently reading. | + | |
- | 4. The Docker daemon streamed that output to the Docker client, which sent it | + | |
- | to your terminal. | + | |
- | + | ||
- | To try something more ambitious, you can run an Ubuntu container with: | + | |
- | $ docker run -it ubuntu bash | + | |
- | + | ||
- | Share images, automate workflows, and more with a free Docker ID: | + | |
- | | + | |
- | + | ||
- | For more examples and ideas, visit: | + | |
- | | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | Now we can install the mysql image as follows: | + | |
<sxh bash> | <sxh bash> | ||
Line 132: | Line 231: | ||
cloudfoundry/ | cloudfoundry/ | ||
ansibleplaybookbundle/ | ansibleplaybookbundle/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===Download (pull) MySQL)=== | ||
+ | <sxh bash> | ||
[root@localhost ~]# docker pull mysql | [root@localhost ~]# docker pull mysql | ||
Using default tag: latest | Using default tag: latest | ||
Line 144: | Line 248: | ||
[root@localhost ~]# docker images | [root@localhost ~]# docker images | ||
REPOSITORY | REPOSITORY | ||
- | mysql latest | ||
hello-world | hello-world | ||
- | mysql/ | + | mysql |
</ | </ | ||
- | + | ===Start the MySQL=== | |
- | We can see now, that I have installed | + | We can see now, that I have installed |
<sxh bash> | <sxh bash> | ||
- | [root@localhost ~]# docker run --name | + | [root@postgresqlmaster yum.repos.d]# docker run --name |
- | 0cb5ef2781b253a98f67028ca7f9b2e6934ee8560718401f54bd46e07a9972d6 | + | d434caf757cfc946d074fbabe44c9a14117d18b8e0451d06afb81a94facbe540 |
[root@localhost ~]# | [root@localhost ~]# | ||
</ | </ | ||
+ | ===Login to the host=== | ||
+ | <sxh bash> | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | CONTAINER ID IMAGE | ||
+ | d434caf757cf | ||
+ | [root@postgresqlmaster yum.repos.d]# | ||
+ | root@d434caf757cf:/# | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ===Connect to the DB=== | ||
+ | And voila we can connect to the DB :) | ||
+ | <sxh bash> | ||
+ | [root@localhost ~]# docker exec -it d434caf757c mysql -uroot -p <- ' | ||
+ | Enter password: | ||
+ | Welcome to the MySQL monitor. | ||
+ | Your MySQL connection id is 14 | ||
+ | Server version: 8.0.11 MySQL Community Server - GPL | ||
+ | |||
+ | Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. | ||
+ | |||
+ | Oracle is a registered trademark of Oracle Corporation and/or its | ||
+ | affiliates. Other names may be trademarks of their respective | ||
+ | owners. | ||
+ | |||
+ | Type ' | ||
+ | mysql> | ||
+ | </ | ||
+ | ===Check Logs=== | ||
We can check the logs of the installation as follows: | We can check the logs of the installation as follows: | ||
Line 235: | Line 367: | ||
Finally, we can connect to the mysql, by running the mysql command from the docker: | Finally, we can connect to the mysql, by running the mysql command from the docker: | ||
- | |||
- | <sxh bash> | ||
- | [root@localhost ~]# docker exec -it mysql2 mysql -uroot -p <- ' | ||
- | Enter password: | ||
- | Welcome to the MySQL monitor. | ||
- | Your MySQL connection id is 14 | ||
- | Server version: 8.0.11 MySQL Community Server - GPL | ||
- | |||
- | Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. | ||
- | |||
- | Oracle is a registered trademark of Oracle Corporation and/or its | ||
- | affiliates. Other names may be trademarks of their respective | ||
- | owners. | ||
- | |||
- | Type ' | ||
- | mysql> | ||
- | </ | ||
- | |||
====Mongo Configuration==== | ====Mongo Configuration==== |