From de8503f2630bfebe0d94135db499850ae34bd30d Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: May 12 2017 07:44:09 +0000 Subject: [PATCH 1/3] add info about standalone containers Signed-off-by: Tomas Tomecek --- diff --git a/source/development/building-modules.rst b/source/development/building-modules.rst index 985f94c..e28aacb 100644 --- a/source/development/building-modules.rst +++ b/source/development/building-modules.rst @@ -10,6 +10,7 @@ Building Modules building-modules/developing building-modules/building-local building-modules/containers-local + building-modules/standalone-containers building-modules/adding-modules-to-fedora building-modules/building-infra building-modules/containers-infra diff --git a/source/development/building-modules/standalone-containers.rst b/source/development/building-modules/standalone-containers.rst new file mode 100644 index 0000000..da8a75c --- /dev/null +++ b/source/development/building-modules/standalone-containers.rst @@ -0,0 +1,77 @@ +Standalone containers +===================== + + +About +----- + +Standalone containers enable you to use containers in a similar way as you use +traditional system services. The goal is to preserve muscle memory so you don't +have to learn new commands while still be able to work with containers. + + +Requirements +------------ + +- Only a single instance of a standalone container is supported to run on a host. +- Services are managed via systemd unit files. +- Containers are installed to a system. +- There is no dedicated network namespace. +- Configuration is stored in same locations on host as non-containerized service. +- Persistent data can be found in the same locations on host as for non-containerized service. +- Service presence, configuration and persistent data are tracked by RPM database. +- Application lifecycle is close to services deployed as RPMs. +- Some commands may need to be executed inside container (by doing exec). + + +Quick how-to +------------ + +We utilize atomic command to install a container image on a host. + +In order to get files from container image to host, you should have this +directory structure inside your container image: + +:: + + / + ├── exports + │   ├── hostfs + │   │   ├── etc + │   │   │   ├── + │   │   └── usr + │   │   └── + │   └── service.template + +- **exports** directory is what atomic uses, it is in root of the container image +- **hostfs** is a tree of directories and files which will land on host, tracked by a generated RPM +- **service.template** is systemd unit file to start and stop the service, it can look like this: + +:: + + [Unit] + Description="Standalone container version of NGINX webserver." + + [Service] + ExecStartPre=/usr/bin/docker create -t -i -v /etc/nginx:/etc/nginx/:ro --net=host -v /usr/share/nginx:/usr/share/nginx/:ro --name nginx-container modularitycontainers/nginx + ExecStart=/usr/bin/docker start -a nginx-container + ExecStop=/usr/bin/docker stop nginx-container + ExecStopPost=/usr/bin/docker rm -f nginx-container + + [Install] + WantedBy=multi-user.target + + +Once the image is built, you can install it like this: + +:: + + $ atomic install --storage=docker --system-package=yes docker:modularitycontainers/nginx + + +There is no released version of atomic with this functionality, yet. + + +For more information, please see the blog post about `system containers +`__. +Standalone containers use the same technology. From c42433880497ececcfcc1f8f5987a3a49743f291 Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: May 12 2017 07:44:09 +0000 Subject: [PATCH 2/3] improve makefile Signed-off-by: Tomas Tomecek --- diff --git a/Dockerfile b/Dockerfile index ff19aac..b44556d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ -FROM fedora -RUN dnf -y install httpd git make -RUN dnf -y install python3-sphinx +FROM fedora:25 +RUN dnf -y install httpd git make python3-sphinx RUN mkdir /source ADD ["Makefile", "/"] ADD ["build-start.sh", "/"] From 6b0150ff80269d732e16680487ff70e81c1fe8a2 Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: May 12 2017 08:31:59 +0000 Subject: [PATCH 3/3] standalone containers: address comments - rewrite Signed-off-by: Tomas Tomecek --- diff --git a/source/development/building-modules/standalone-containers.rst b/source/development/building-modules/standalone-containers.rst index da8a75c..3194eee 100644 --- a/source/development/building-modules/standalone-containers.rst +++ b/source/development/building-modules/standalone-containers.rst @@ -7,45 +7,75 @@ About Standalone containers enable you to use containers in a similar way as you use traditional system services. The goal is to preserve muscle memory so you don't -have to learn new commands while still be able to work with containers. +have to learn new commands while still being able to work with containers. Requirements ------------ -- Only a single instance of a standalone container is supported to run on a host. +- Only a single instance of a standalone container is supported to run on a host (installation of the same container image twice won't be successful). - Services are managed via systemd unit files. - Containers are installed to a system. - There is no dedicated network namespace. -- Configuration is stored in same locations on host as non-containerized service. -- Persistent data can be found in the same locations on host as for non-containerized service. -- Service presence, configuration and persistent data are tracked by RPM database. +- Configuration is stored in the same locations on the host as a non-containerized service. +- Persistent data can be found in the same locations on the host as for non-containerized service. +- Service presence, configuration and persistent data are tracked by the RPM database. - Application lifecycle is close to services deployed as RPMs. -- Some commands may need to be executed inside container (by doing exec). +- Some commands may need to be executed inside the container since the service is not running directly on host. Quick how-to ------------ -We utilize atomic command to install a container image on a host. +We utilize the atomic command to install a container image on a host. -In order to get files from container image to host, you should have this -directory structure inside your container image: +In order to get files from a container image to the host, you should have a specific +directory structure inside your container image. Here's an example of nginx container image: :: / - ├── exports - │   ├── hostfs - │   │   ├── etc - │   │   │   ├── - │   │   └── usr - │   │   └── - │   └── service.template - -- **exports** directory is what atomic uses, it is in root of the container image -- **hostfs** is a tree of directories and files which will land on host, tracked by a generated RPM -- **service.template** is systemd unit file to start and stop the service, it can look like this: + └── exports + └── hostfs + ├── etc + │   └── nginx + │   ├── conf.d + │   ├── default.d + │   ├── fastcgi.conf + │   ├── fastcgi.conf.default + │   ├── fastcgi_params + │   ├── fastcgi_params.default + │   ├── koi-utf + │   ├── koi-win + │   ├── mime.types + │   ├── mime.types.default + │   ├── nginx.conf + │   ├── nginx.conf.default + │   ├── scgi_params + │   ├── scgi_params.default + │   ├── uwsgi_params + │   ├── uwsgi_params.default + │   └── win-utf + └── usr + ├── lib + │   └── systemd + │   └── system + │   └── nginx-container.service + └── share + └── nginx + └── html + ├── 404.html + ├── 50x.html + ├── index.html + ├── nginx-logo.png + └── poweredby.png + + +- **exports** directory is what atomic uses, it is in a root of the container image +- **hostfs** is a tree of directories and files which will land on the host, tracked by a generated RPM +- a systemd unit :code:`nginx-container.service`, which controls the containerized nginx, is placed in :code:`/exports/hostfs/usr/lib/systemd/system` + +Here's the mentioned :code:`nginx-container.service`: :: @@ -66,12 +96,13 @@ Once the image is built, you can install it like this: :: - $ atomic install --storage=docker --system-package=yes docker:modularitycontainers/nginx + $ atomic install docker:modularitycontainers/nginx -There is no released version of atomic with this functionality, yet. +There is no released version of atomic with this functionality, yet. The +version of atomic command built `in this copr repo `__ contains the functionality to +install standalone container image. - -For more information, please see the blog post about `system containers -`__. -Standalone containers use the same technology. +Most of the principles of standalone containers are based on the model & +technology of system containers. If you would like to know more about system +containers read `the blog post `__.