docker_basic_configuration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docker_basic_configuration [2020/01/23 12:39] – [Installation] andonovjdocker_basic_configuration [2020/01/25 04:02] (current) – external edit 127.0.0.1
Line 13: Line 13:
 Docker is easily installed as follows: Docker is easily installed as follows:
  
-===Install the package===+====Install the package====
 You can install the package using your favorite package manager, in my case "yum" You can install the package using your favorite package manager, in my case "yum"
 <sxh bash> <sxh bash>
Line 24: Line 24:
 gpgkey=https://yum.dockerproject.org/gpg gpgkey=https://yum.dockerproject.org/gpg
 [root@postgresqlmaster yum.repos.d]# [root@postgresqlmaster yum.repos.d]#
-[root@postgresqlmaster yum.repos.d]# yum install docker-engine -y+[root@postgresqlpgpool app]# yum install docker-ce docker-ce-cli containerd.io
 Loaded plugins: fastestmirror, langpacks Loaded plugins: fastestmirror, langpacks
 Loading mirror speeds from cached hostfile Loading mirror speeds from cached hostfile
- * base: mirror-pl.kielcetechnologypark.net + * base: ftp.cvut.cz 
- * extras: ftp.agh.edu.pl + * extras: ftp.cvut.cz 
- * updates: mirror.hosting90.cz + * updates: ftp.cvut.cz
-base                                                                                                                                                                                                | 3.6 kB  00:00:00 +
-dockerrepo                                                                                                                                                                                          | 2.9 kB  00:00:00 +
-extras                                                                                                                                                                                              | 2.9 kB  00:00:00 +
-pgdg10                                                                                                                                                                                              | 3.6 kB  00:00:00 +
-pgdg11                                                                                                                                                                                              | 3.6 kB  00:00:00 +
-pgdg94                                                                                                                                                                                              | 3.6 kB  00:00:00 +
-pgdg95                                                                                                                                                                                              | 3.6 kB  00:00:00 +
-pgdg96                                                                                                                                                                                              | 3.6 kB  00:00:00 +
-updates                                                                                                                                                                                             | 2.9 kB  00:00:00 +
-dockerrepo/primary_db                                                                                                                                                                                34 kB  00:00:00+
 Resolving Dependencies Resolving Dependencies
 --> Running transaction check --> Running transaction check
----> Package docker-engine.x86_64 0:17.05.0.ce-1.el7.centos will be installed +---> Package containerd.io.x86_64 0:1.2.10-3.2.el7 will be installed 
---> Processing Dependency: docker-engine-selinux >= 17.05.0.ce-1.el7.centos for package: docker-engine-17.05.0.ce-1.el7.centos.x86_64 +---> Package docker-ce.x86_64 3:19.03.5-3.el7 will be installed 
---> Processing Dependencylibcgroup for package: docker-engine-17.05.0.ce-1.el7.centos.x86_64 +---> Package docker-ce-cli.x86_64 1:19.03.5-3.el7 will be installed 
---> Processing Dependency: libltdl.so.7()(64bit) for package: docker-engine-17.05.0.ce-1.el7.centos.x86_64 +--> Finished Dependency Resolution
---> Running transaction check +
----> Package docker-engine-selinux.noarch 0:17.05.0.ce-1.el7.centos will be installed +
-Installed: +
-  docker-engine.x86_64 0:17.05.0.ce-1.el7.centos +
-******************************************************************************************************************************** +
-Dependency Installed: +
-  audit-libs-python.x86_64 0:2.8.5-4.el7  checkpolicy.x86_64 0:2.5-8.el7              docker-engine-selinux.noarch 0:17.05.0.ce-1.el7.centos  libcgroup.x86_64 0:0.41-21.el7     libsemanage-python.x86_64 0:2.5-14.el7 +
-  libtool-ltdl.x86_64 0:2.4.2-22.el7_3    policycoreutils-python.x86_64 0:2.5-33.el7  python-IPy.noarch 0:0.75-6.el7                          setools-libs.x86_64 0:3.3.8-4.el7+
  
-Dependency Updated+Dependencies Resolved 
-  audit.x86_64 0:2.8.5-4.el7                                          audit-libs.x86_64 0:2.8.5-4.el7                                          policycoreutils.x86_64 0:2.5-33.el7+ 
 +=========================================================================================================================================================================================================================== 
 + Package                                              Arch                                          Version                                                  Repository                                               Size 
 +=========================================================================================================================================================================================================================== 
 +Installing
 + containerd.io                                        x86_64                                        1.2.10-3.2.el7                                           docker-ce-stable                                         23 M 
 + docker-ce                                            x86_64                                        3:19.03.5-3.el7                                          docker-ce-stable                                         24 M 
 + docker-ce-cli                                        x86_64                                        1:19.03.5-3.el7                                          docker-ce-stable                                         39 M 
 + 
 +Transaction Summary 
 +=========================================================================================================================================================================================================================== 
 +Install  3 Packages 
 + 
 +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:docker-ce-cli-19.03.5-3.el7.x86_64                                                                                                                                                                    1/3 
 +  Installing containerd.io-1.2.10-3.2.el7.x86_64                                                                                                                                                                     2/3 
 +  Installing : 3:docker-ce-19.03.5-3.el7.x86_64                                                                                                                                                                        3/3 
 +  Verifying  : containerd.io-1.2.10-3.2.el7.x86_64                                                                                                                                                                     1/3 
 +  Verifying  1:docker-ce-cli-19.03.5-3.el7.x86_64                                                                                                                                                                    2/3 
 +  Verifying  : 3:docker-ce-19.03.5-3.el7.x86_64                                                                                                                                                                        3/3 
 + 
 +Installed: 
 +  containerd.io.x86_64 0:1.2.10-3.2.el7                                     docker-ce.x86_64 3:19.03.5-3.el7                                     docker-ce-cli.x86_64 1:19.03.5-3.el7
  
 Complete! Complete!
 +[root@postgresqlpgpool app]# service docker start
 +Redirecting to /bin/systemctl start docker.service
 +[root@postgresqlpgpool app]
 </sxh> </sxh>
  
-===Start the service=== +====Start the service====
 <sxh bash> <sxh bash>
 [root@postgresqlmaster yum.repos.d]# service docker start [root@postgresqlmaster yum.repos.d]# service docker start
Line 92: Line 105:
 </sxh> </sxh>
  
-===Run "Hello World"===+====Run "Hello World"====
 <sxh bash> <sxh bash>
 [root@postgresqlmaster yum.repos.d]# docker run hello-world [root@postgresqlmaster yum.repos.d]# docker run hello-world
Line 137: 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 Configuration====+====MySQL Docker====
 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 187: Line 200:
 </sxh> </sxh>
  
-By default the "hello-world" image is always installed and can be run as follows: +===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 'hello-world:latest' locally +
-latest: Pulling from library/hello-world +
-9db2ca6ccae0: Pull complete +
-Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc +
-Status: Downloaded newer image for hello-world:latest +
- +
-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 "hello-world" image from the Docker Hub. +
-    (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: +
- https://hub.docker.com/ +
- +
-For more examples and ideas, visit: +
- https://docs.docker.com/engine/userguide/ +
-</sxh> +
- +
- +
-Now we can install the mysql image as follows:+
  
 <sxh bash> <sxh bash>
Line 250: Line 231:
 cloudfoundry/cf-mysql-ci                               Image used in CI of cf-mysql-release            0 cloudfoundry/cf-mysql-ci                               Image used in CI of cf-mysql-release            0
 ansibleplaybookbundle/mysql-apb                        An APB which deploys RHSCL MySQL                0                                       [OK] ansibleplaybookbundle/mysql-apb                        An APB which deploys RHSCL MySQL                0                                       [OK]
 +
 +</sxh>
 +
 +===Download (pull) MySQL)===
 +<sxh bash>
 [root@localhost ~]# docker pull mysql [root@localhost ~]# docker pull mysql
 Using default tag: latest Using default tag: latest
Line 262: Line 248:
 [root@localhost ~]# docker images [root@localhost ~]# docker images
 REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
-mysql                latest              5dbe5b6313e1        13 hours ago        445MB 
 hello-world          latest              2cb0d9787c4d        2 weeks ago         1.85kB hello-world          latest              2cb0d9787c4d        2 weeks ago         1.85kB
-mysql/mysql-server   latest              02d081b9c73e        3 months ago        300MB+mysql   latest              02d081b9c73e        3 months ago        300MB
 </sxh> </sxh>
  
- +===Start the MySQL=== 
-We can see now, that I have installed 2 mysqls, we can initiate a new container for mysql image as follows: +We can see now, that I have installed mysql, we can initiate a new container for mysql image as follows:
  
 <sxh bash> <sxh bash>
-[root@localhost ~]# docker run --name mysql2 -e MYSQL_ROOT_PASSWORD='oracle' -d mysql/mysql-server:latest +[root@postgresqlmaster yum.repos.d]#  docker run --name mysql -e MYSQL_ROOT_PASSWORD='oracle' -d mysql 
-0cb5ef2781b253a98f67028ca7f9b2e6934ee8560718401f54bd46e07a9972d6+d434caf757cfc946d074fbabe44c9a14117d18b8e0451d06afb81a94facbe540
 [root@localhost ~]# [root@localhost ~]#
 </sxh> </sxh>
  
 +===Login to the host===
 +<sxh bash>
 +[root@postgresqlmaster yum.repos.d]# docker container ls
 +CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
 +d434caf757cf        mysql               "docker-entrypoint..."   7 seconds ago       Up 6 seconds        3306/tcp, 33060/tcp   mysql
 +[root@postgresqlmaster yum.repos.d]# docker exec -it d434caf757cf /bin/bash
 +root@d434caf757cf:/#
 +
 +</sxh>
 +
 +
 +===Connect to the DB===
 +And voila we can connect to the DB :)
 +<sxh bash>
 +[root@localhost ~]# docker exec -it d434caf757c mysql -uroot -p   <- 'oracle'
 +Enter password:
 +Welcome to the MySQL monitor.  Commands end with ; or \g.
 +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 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 +mysql>
 +</sxh>
  
 +===Check Logs===
 We can check the logs of the installation as follows: We can check the logs of the installation as follows:
  
Line 353: 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   <- 'oracle' 
-Enter password: 
-Welcome to the MySQL monitor.  Commands end with ; or \g. 
-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 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
-mysql> 
-</sxh> 
- 
  
 ====Mongo Configuration==== ====Mongo Configuration====
  • docker_basic_configuration.1579783177.txt.gz
  • Last modified: 2020/01/23 20:39
  • (external edit)