Changes

From SME Server
Jump to navigationJump to search
2,821 bytes removed ,  19:39, 10 March 2022
no edit summary
Line 1: Line 1:  
{{WIP box}}
 
{{WIP box}}
 
Placeholder for anything to do with Docker (https://docker.com)
 
Placeholder for anything to do with Docker (https://docker.com)
{{Note box| All info is based on SME Server 9 only but I have just started to test on v10 - see notes below
+
{{Note box| The contrib has been built from the original notes and I use it to permanently run Rocketchat }}
Your host server must have internet access.
     −
Some testing below was originally done on a virtual SME9 under Virtualbox. Yes, Docker also run on VM's :-)
+
=== Version ===
 
+
{{ #smeversion: smeserver-docker }}
The contrib has been built from the original notes and I use it to permanently run Rocketchat.
  −
}}
      
'''You can discuss all things related to this page on the forums [http://forums.contribs.org/index.php/topic,51181.0.html here]'''
 
'''You can discuss all things related to this page on the forums [http://forums.contribs.org/index.php/topic,51181.0.html here]'''
Line 58: Line 55:     
===Contrib===
 
===Contrib===
There is a contrib that will set up a lot of this for you in the Reetp Repo:
  −
  −
https://wiki.contribs.org/User:ReetP
  −
  −
Add the reetpTest repo:
  −
  −
yum --enablerepo=reetpTest,epel install smeserver-docker
  −
  −
Most of the settings in the Manual Installation below are replicated into the contrib with templates
  −
  −
====Docker Images====
     −
These can be pulled using docker itself as per Manual Installation below. Note that some require a higher version of docker. Regrettably I can't change that!
+
yum --enablerepo=smecontribs,epel install smeserver-docker
   −
Alternatively you can create a docker-compose.yml file directly, or via templates, in:
+
We looking at building an updated docker-compose rpm and using the docker-ce-stable repo
   −
/home/e-smith/files/docker/configs
+
We have added the docker repo to Extarepositories
   −
docker-compose will automatically run this at boot.
+
https://wiki.contribs.org/Extrarepositories
 
  −
Create you compose file and then run this from the configs directory
  −
 
  −
docker-compose up -d
      
====Networking====
 
====Networking====
   −
{{Note box | See Issues and other comments further down re host/bridged networking}}
+
{{WIP box | This is still a work in progress. the following are notes fro reference only}}
    
Docker attempts to guess what network to use and sets a bridged interface for it.
 
Docker attempts to guess what network to use and sets a bridged interface for it.
Line 125: Line 107:  
docker exec -t -i -u root <container_name> /bin/bash
 
docker exec -t -i -u root <container_name> /bin/bash
   −
===Manual Installation===
+
====Configuration====
 
  −
Note that most of the following is now in the contrib. See above.
  −
 
  −
Docker requires some RPM's that are not available in the default upstream repo's. So we need to enable the epel repo first. See ''[[epel]]''
  −
 
  −
Then we can install Docker and it's dependencies:
  −
yum install docker-io --enablerepo=epel
  −
 
  −
 
  −
Make the Docker service start at boot time:
  −
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S95docker
  −
chkconfig docker on
  −
config set docker service
  −
config setprop docker status enabled
  −
 
     −
====Configuration====
+
config show docker
Docker comes with a configuration file located at:
+
  status enabled/disabled - enabled by default
  /etc/sysconfig/docker
+
  iptables true/false - false by default to prevent docker manipulating iptables
In this file you can set default parameters which are applicable to all containers run by Docker. By default it holds no arguments. All arguments can also be set manually when starting a container, in which case each individual container can have it's specific parameters.  To see a list all available arguments that can be used in the Docker configuration file enter:
  −
  docker -h
      +
config show containerd
 +
status enabled/disabled - enabled by default
    
====SME Server specifics====
 
====SME Server specifics====
Line 156: Line 123:  
  '''/home/e-smith/files/docker'''
 
  '''/home/e-smith/files/docker'''
   −
We want this to be the default location for all Docker data on SME Server, so we add the '-g' argument and the desired path to the storage location to the docker configuration file like this:
+
We now have systemd config files
 +
 
 +
Note to self:
 +
It is ''important'' that you adjust the config file ''before'' you start using docker otherwise it will create it's default storage location in /var/lib/docker.
 +
 
 +
You can still change the storage location in a later stage by copying all data to the new location you've defined with the -g argument.
 +
 
 +
Or just restart with the new location.
   −
  # /etc/sysconfig/docker
+
  systemctl status docker
  #
+
  systemctl status containerd
# Other arguments to pass to the docker daemon process
  −
# These will be parsed by the sysv initscript and appended
  −
# to the arguments list passed to docker -d
  −
  −
other_args="-g /home/e-smith/files/docker -H unix:///var/run/docker.sock"
        −
Since the Docker service will always check this configuration file upon (re)start, it will automatically pick up the arguments you have provided and act accordingly. That also implies that you can have multiple (but ''not'' simultaneously) storage locations if you omit the configuration file and add arguments manually on the command line.
+
==Using a Docker image==
   −
The second argument '-H unix:///var/run/docker.sock' will tell Docker where to find it's socket to bind.
+
You should generally be prefer to use docker-compose for images.
    +
The compose file is templated and makes managing docker images much easier.
   −
It is ''important'' that you adjust the config file ''before'' you start using docker otherwise it will create it's default storage location in /var/lib/docker.
+
A fragment needs adding here:
   −
You can still change the storage location in a later stage by copying all data to the new location you've defined with the -g argument.
+
/etc/e-smith/templates-custom/home/e-smith/files/docker/configs/docker-compose.yml
    +
Each template fragment needs to be JSON compliant to work
   −
Once the above changes have been made, the Docker service can be started and Docker will create it's new storage layout in /home/e-smith/files/docker.
  −
service docker start
     −
You can check if the docker deamon is running:
+
===general===
service docker status
+
The following methods and notes are left for reference.
and if it created the storage layout correctly:
  −
ls -l /home/e-smith/files/docker/
     −
==Using a Docker image==
+
By default, there are pre-built images available from the official [https://registry.hub.docker.com/ Docker Hub]. In our examples we will use the pre-built centos7 image.
By default, there are pre-build images available from the official [https://registry.hub.docker.com/ Docker Hub]. In our examples we will use the pre-build centos6 image.
      
To get a list of all available Centos images you can use:
 
To get a list of all available Centos images you can use:
Line 194: Line 160:     
===Downloading a docker image===
 
===Downloading a docker image===
To download the centos6 image to your local server, issue the following command as root:
+
To download the centos7 image to your local server, issue the following command as root:
  docker pull centos:centos6
+
  docker pull centos:centos7
where the syntax is 'centos' as the main repository and 'centos6' the specific version. Would you issue only 'docker pull centos', then all centos versions will be downloaded. So be specific.
+
where the syntax is 'centos' as the main repository and 'centos7' the specific version. Would you issue only 'docker pull centos', then all centos versions will be downloaded. So be specific.
    
Once the image has been downloaded, you can check your local images by issuing:
 
Once the image has been downloaded, you can check your local images by issuing:
 
  docker images
 
  docker images
 +
 
The listing included the Image ID and Name. These are important to run additional commands when the container is running.
 
The listing included the Image ID and Name. These are important to run additional commands when the container is running.
       
===Running a docker container===
 
===Running a docker container===
Now that we have downloaded the centos6 image it's time to give it a spin. To start the cento6 container we can issue the following command:
+
Now that we have downloaded the centos7 image it's time to give it a spin. To start the cento6 container we can issue the following command:
  docker run -t -i --net="host" centos:centos6 bash
+
  docker run -t -i --net="host" centos:centos7 bash
This will tell docker to run the centos6 container interactively from the local centos repo, use the host network interface and start bash. After a few seconds you will be presented with the bash prompt inside the centos6 container:
+
This will tell docker to run the centos6 container interactively from the local centos repo, use the host network interface and start bash. After a few seconds you will be presented with the bash prompt inside the centos7 container:
 
  bash-4.1#
 
  bash-4.1#
 
and to check if we are really inside the centos6 container we can display the release version:
 
and to check if we are really inside the centos6 container we can display the release version:
 
  cat /etc/redhat-release
 
  cat /etc/redhat-release
 
which will result in:
 
which will result in:
  CentOS release 6.5 (Final)
+
  CentOS release 7.8 (Final)
 
From here you can use the normal commands like yum etc.
 
From here you can use the normal commands like yum etc.
   Line 221: Line 188:  
===Copy docker images===
 
===Copy docker images===
 
Docker images are stored on your local server. If you want to run the image on another machine you first have to take the image out of your local image repository and save the image in a transferable format. For this the ''save'' the image in .tar format. To get a listing of all available images on your local server:
 
Docker images are stored on your local server. If you want to run the image on another machine you first have to take the image out of your local image repository and save the image in a transferable format. For this the ''save'' the image in .tar format. To get a listing of all available images on your local server:
 +
 
  docker images
 
  docker images
 +
 
will result in (example):
 
will result in (example):
 +
 
  [root@sme9 ~]# docker images
 
  [root@sme9 ~]# docker images
 
  REPOSITORY                TAG                IMAGE ID            CREATED            VIRTUAL SIZE
 
  REPOSITORY                TAG                IMAGE ID            CREATED            VIRTUAL SIZE
 
  sme9                      6.5                55db4355a2de        46 minutes ago      854.7 MB
 
  sme9                      6.5                55db4355a2de        46 minutes ago      854.7 MB
 
  leszekk/centos_minimalcd  6.5                bc56fa8f1204        8 months ago        452.6 MB
 
  leszekk/centos_minimalcd  6.5                bc56fa8f1204        8 months ago        452.6 MB
 +
 
To create a copy of our sme9 image and save it as 'copyofsme9 you need to enter the following command:
 
To create a copy of our sme9 image and save it as 'copyofsme9 you need to enter the following command:
 
  docker save sme9:6.5 > /tmp/copyofsme9.tar
 
  docker save sme9:6.5 > /tmp/copyofsme9.tar
 +
 
which will result in a copyofsme9.tar file in your /tmp directory of your local server. You can now copy/move this file to another server or simply archive it for later usage.
 
which will result in a copyofsme9.tar file in your /tmp directory of your local server. You can now copy/move this file to another server or simply archive it for later usage.
    
To use the copyofsme9.tar file on another server and use it on that server with Docker, we can load it into the repository of the new server:
 
To use the copyofsme9.tar file on another server and use it on that server with Docker, we can load it into the repository of the new server:
 
  docker load -i < /downloads/copyofsme9.tar
 
  docker load -i < /downloads/copyofsme9.tar
 +
 
After Docker has loaded the file, you can check it's availability by executing: docker images and you can use it just like any other image on your new server. You can use the ''save'' and ''load'' commands to clean up your local repository and share copies of your image.
 
After Docker has loaded the file, you can check it's availability by executing: docker images and you can use it just like any other image on your new server. You can use the ''save'' and ''load'' commands to clean up your local repository and share copies of your image.
   Line 253: Line 226:  
===Docker Name resolution===
 
===Docker Name resolution===
   −
Normally you could add the DNS directly in the file /etc/sysconfig/docker, if you don't do that, your docker container could ping an IP, but never do the domain name translation. This is the dns of opendns, but you could change them.
  −
  −
# cat /etc/sysconfig/docker
  −
  −
# /etc/sysconfig/docker
  −
#
  −
# Other arguments to pass to the docker daemon process
  −
# These will be parsed by the sysv initscript and appended
  −
# to the arguments list passed to docker -d
   
   
 
   
other_args="--dns 208.67.220.220 --dns 208.67.220.222"
+
Other DNS can be added to the unit file or daemon.json - see further below for details.
   −
or you could add directly from the command line
+
Or you could add directly from the command line
 
  docker run -i -t -dns 208.67.220.220 -dns 208.67.220.222  sme9_real:6.5 /bin/bash
 
  docker run -i -t -dns 208.67.220.220 -dns 208.67.220.222  sme9_real:6.5 /bin/bash
   Line 300: Line 264:  
* https://blog.codecentric.de/en/2014/02/docker-registry-run-private-docker-image-repository/
 
* https://blog.codecentric.de/en/2014/02/docker-registry-run-private-docker-image-repository/
   −
  −
===Docker notes===
  −
Loose notes:
  −
docker=service
  −
access=public
  −
status=enabled
      
==Docker Compose==
 
==Docker Compose==
   −
The binary is included in the smeserver-docker contrib.
+
https://github.com/docker/compose/releases/tag/1.29.2
   −
The latest version that you can use with the installed version of docker (currently 1.7.1) is docker-compose version 1.5.2
+
  curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
https://github.com/docker/compose/releases/tag/1.5.2
  −
 
  −
  curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
   
  chmod +x /usr/local/bin/docker-compose
 
  chmod +x /usr/local/bin/docker-compose
    
==Shipyard web GUI==
 
==Shipyard web GUI==
 +
Deprecated
 
There is a separate page on how to install Shipyard, the Docker web GUI [http://wiki.contribs.org/Shipyard here]
 
There is a separate page on how to install Shipyard, the Docker web GUI [http://wiki.contribs.org/Shipyard here]
   Line 326: Line 282:     
==Things to do==
 
==Things to do==
* Get the [https://github.com/shipyard/shipyard shipyard GUI] going
+
 
* A LOT more ;-)
      
==Issues==
 
==Issues==
 +
 +
This was a v9 issue. Leaving for reference.
    
You will find that if you use 'host' networking docker will set /sys as Read Only and you will get an error with the raid_check as per this bug
 
You will find that if you use 'host' networking docker will set /sys as Read Only and you will get an error with the raid_check as per this bug
Line 339: Line 296:  
==Koozai SME v10==
 
==Koozai SME v10==
   −
Some basic scratchpad notes as I go
+
See above for contrib that is being developed. The following are old notes.
    
https://docs.docker.com/engine/install/centos/
 
https://docs.docker.com/engine/install/centos/

Navigation menu