Showing posts with label Microservices. Show all posts
Showing posts with label Microservices. Show all posts

May 2, 2018

Operator Framework: Building application with kubernetes

Yesterday redhat announced a new framework to build applications with kubernetes:
The concept of operator framework was build in 2016 from coreos.
CoreOS released the same announcement as redhat. Not really amazing, because:

Here some text snippets from the announcement:
The Operator Framework includes:
  • Operator SDK: Enables developers to build Operators based on their expertise without requiring knowledge of Kubernetes API complexities.
  • Operator Lifecycle Management: Oversees installation, updates, and management of the lifecycle of all of the Operators (and their associated services) running across a Kubernetes cluster.
  • Operator Metering (joining in the coming months): Enables usage reporting for Operators that provide specialized services.
If you are really interested and familiar with kubernetes you can start here.
Let' s wait for the first updates und first success stories...

Apr 17, 2018

Docker: How to build you own container with your own application

atThere are many tutorials out there, how to create a docker container with a apache webserver inside or a nginx.
But you can hardly find a manual how to build your own docker container without pulling everything from a foreign repository.
Why should you not pull everything from foreign repositories?

You should read this article or this:
But since each phase of the development pipeline is built at a different time, …
…you can’t be sure that the same version of each dependency in the development version also got into your production version.
That is a good point.

As considered in this article you can put some more constraints into your docker file: 
FROM ubuntu:14.04.
or even
FROM ubuntu:0bf3461984f2fb18d237995e81faa657aff260a52a795367e6725f0617f7a56c
And that is the point where i tell you: Create a process to build your own docker containers from scratch and distribute them with your own repository or copy them to all your docker nodes (s. here)

So here the steps to create your own container from a local directory (here ncweb):

# ls -l ncweb/
total 12
-rw-r--r--    1 root     root            90 Nov 26 10:06 Dockerfile
-rw-r--r--    1 root     root           255 Nov 26 11:29 index.html
-rw-r--r--    1 root     root             0 Nov 26 11:29 logfile
-rwxr--r--    1 root     root           176 Nov 26 11:29 ncweb.sh  
The Dockerfile contains the following:

# ls -l ncweb/
alpine:~# cat ncweb/Dockerfile 
FROM alpine
WORKDIR /tmp
RUN mkdir ncweb
ADD .  /tmp
ENTRYPOINT [ "/tmp/ncweb.sh" ]
Into this directory you have to put everything you need, e.g. a complete JDK or your binaries or ...

And then change into this directory and build your container:

ncweb# docker build -t ncweb:0.2 .
The distribution to other docker nodes can be done like this:

# docker save ncweb:0.3 | ssh 192.168.178.47 docker load 
For more details read this posting.


Related posts:



Mar 10, 2018

Docker-CE on Ubuntu 17.10 (Artful Aardvark) (2)

Three months ago i installed docker on my ubuntu 17.10. At those days there was no straight forward howto on docher.com.

Now the installation is listed on docker.com:


The installation manual can be found here.

root@zerberus:~# apt-get install apt-transport-https ca-certificates curl   software-properties-common
root@zerberus:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  OK
root@zerberus:~# apt-key fingerprint 0EBFCD88  pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
  uid        [ unbekannt ] Docker Release (CE deb)
sub   rsa4096 2017-02-22 [S]
root@zerberus:~# add-apt-repository \
>    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
>    $(lsb_release -cs) \
>    stable"
root@zerberus:~# apt update

root@zerberus:~# apt install docker-ce
And then a check:
root@zerberus:~# docker versionClient:
 Version:    17.12.0-ce
 API version:    1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built:    Wed Dec 27 20:11:14 2017
 OS/Arch:    linux/amd64

Server:
 Engine:
  Version:    17.12.0-ce
  API version:    1.35 (minimum version 1.12)
  Go version:    go1.9.2
  Git commit:    c97c6d6
  Built:    Wed Dec 27 20:09:47 2017
  OS/Arch:    linux/amd64
  Experimental:    false

Related posts:

Feb 11, 2018

Docker-Machine: how to create a docker vm on a remote virtualbox server

After doing some first steps with docker, i wanted to test docker-swarm. Because of the limited resources of my notebook, i was looking for a Linux with a minimal footprint. In the context of setting up VMs for docker-swarm i found a log of articles about doing that with the tool docker-machine.
It sounds like this tool can create VMs just with one command. (here the documentation).

So let's give it a try:
(You have to install docker-machine first, but you do not need to install docker itself)
~$ docker-machine create --driver virtualbox test
Creating CA: /home/schroff/.docker/machine/certs/ca.pem
Creating client certificate: /home/schroff/.docker/machine/certs/cert.pem
Running pre-create checks...
(test) Image cache directory does not exist, creating it at /home/schroff/.docker/machine/cache...
(test) No default Boot2Docker ISO found locally, downloading the latest release...
(test) Latest release for github.com/boot2docker/boot2docker is v17.11.0-ce
(test) Downloading /home/schroff/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.11.0-ce/boot2docker.iso...
(test) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(test) Copying /home/schroff/.docker/machine/cache/boot2docker.iso to /home/schroff/.docker/machine/machines/test/boot2docker.iso...
(test) Creating VirtualBox VM...
(test) Creating SSH key...
(test) Starting the VM...
(test) Check network to re-create if needed...
(test) Found a new host-only adapter: "vboxnet0"
(test) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env test
Wow.
After this command inside my virtualbox a new machine shows up with 1GB RAM, 20 GB HDD (dynamic allocated), 2 network adapters (1x NAT, 1x host only).




But it is not possible to create VMs on a remote Virtualbox server. The CLI does not allow to give a remote server IP:

But for some other environments it is possible to deploy VMs on a remote site:

--vmwarevsphere-vcenter: IP/hostname for vCenter (or ESXi if connecting directly to a single host)
If your preferred virtualization engine supports remote servers, you can check here:

Nevertheless docker-machine is an excellent tool. If you are interested in creating a swarm, read this tutorial.
The homepage of the OS boot2docker can be found here.


Related posts:


Feb 7, 2018

Talking about Microservices: A journey to Docker / Snap / CoreOS / Unbuntu Core / Docker-Swarm

A few months ago (13th august 2017) i started my personal journey into this new hype called microservices:

I thought the best way for me to get in touch was to begin with CoreOS. Within 2 weeks i got some first impressions:

But after these steps i realized, that next step on this road is kubernetes. It is clear that cluster scheduler like kubernetes can not be run on a single machine - so i tried to get another access to microservices: Snap and UbuntuCore:
In november 2017 it was clear, that both UbuntuCore and CoreOS are some building blocks for microservices, but i was not really on the right track.
Back to kubernetes? Kubernetes relies on containers. So i started with docker:
Nearly 3 months later i still did not get in touch with kubernetes - but i think docker swarm is a cluster scheduler, too. And it is really easy to run.

What will i do next? Some tests to failure/failover/failback scenarios. 

Jan 14, 2018

Docker-CE: How to modify containers with overlays / How to add directories to a standard docker image

After some experiments with docker i wanted to run a tomcat with my own configuration (e.g. memory settings, ports, ...).


My first idea was: Download tomcat, configure everything and then build an image.
BUT: After i learned how to use the -v (--volume) flag for adding some file via the docker command to an image i was wondering, wether creating a new image with only the additional files on top of standard tomcat docker image.

So first step is to take a look at all local images:
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
558MB
friendlyhello       latest              976ee2bb47bf        3 days ago          148MB
tomcat              latest              11df4b40749f        8 days ago          558MB
I can use tomcat:latest. (if it is not there just pull it: docker pull tomcat)
Next step is to create a directory and add all the directories which you want to override.
For my example:
mkdir conftomcat
cd conftomcat
mkdir bin
Into the bin directory i put all the files from the tomcat standard container:
# ls bin
bootstrap.jar  catalina-tasks.xml  commons-daemon-native.tar.gz  daemon.sh  setclasspath.sh  startup.sh       tool-wrapper.sh
catalina.sh    commons-daemon.jar  configtest.sh                 digest.sh  shutdown.sh      tomcat-juli.jar  version.sh

Inside the catalina.sh i added -Xmx384M.
In conftomcat i created the following Dockerfile:
FROM tomcat:latest
WORKDIR /usr/local/tomcat/bin
ADD status /usr/local/tomcat/webapps/mystatus
ADD bin /usr/local/tomcat/bin
ENTRYPOINT [ "/usr/local/tomcat/bin/catalina.sh" ]
CMD [ "run"]
And as you can see i added my index.jsp which is inside status (s. this posting).
Ok. Let's see, if my plan works:
#docker build  -t  mytomcat .
ending build context to Docker daemon  375.8kB
Step 1/6 : FROM tomcat:latest
 ---> 11df4b40749f
Step 2/6 : WORKDIR /usr/local/tomcat/bin
 ---> Using cache
 ---> 5696a9ab99cb
Step 3/6 : ADD status /usr/local/tomcat/webapps/mystatus
 ---> 1bceea5af515
Step 4/6 : ADD bin /usr/local/tomcat/bin
 ---> e8d3a386a7f0
Step 5/6 : ENTRYPOINT [ "/usr/local/tomcat/bin/catalina.sh" ]
 ---> Running in a04038032bb7
Removing intermediate container a04038032bb7
 ---> 4c8fda05df18
Step 6/6 : CMD [ "run"]
 ---> Running in cce378648e7a
Removing intermediate container cce378648e7a
 ---> 72ecfe2aa4a7
Successfully built 72ecfe2aa4a7
Successfully tagged mytomcat:latest
and then start:
docker run -p 4001:8080 mytomcat
Let's check the memory settings:
$ ps aux|grep java
root      2313 20.7  8.0 2418472 81236 ?       Ssl  19:51   0:02 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx394M -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
Yes - changed to 384M.
And check the jsp:



Yippie!
As you can see, i have the standard tomcat running with an override inside the configuration to 384M. So it should be easy to add certificates, WARs, ... to such a standard container.


Related posts:

Jan 7, 2018

Review at amazon: Kubernetes: Up & Running

Between christmas and new year i read

The authors state:
"This practical guide shows you how Kubernetes and container technology can help you achieve new levels of velocity, agility, reliability, and efficiency."
I think, yes - this is a practial guide, but within only 166 pages it is far too short to give relevant insights into Kubernetes. There are many commands and YAMLs shown, but the book misses a didactic preparation. Some chapters can only be understand, if you have read some later chapters.

But for only 25€ you get a good start, if you are willing to read the book twice ;-)

If you are interested, take a look at my review at amazon.com. (This time amazon.de refused my review. ;-)

Jan 4, 2018

Docker-Swarm: How to run a mysql database...

After several tests with docker swarm (setting up a swarm, running with more than on master, running a webserver in a swarm) i am thinking about running a mysql database in a swarm.

If you are running a mysql database on one docker host, you have to set up a docker volume, because otherwise data inside the container is gone, if you restart your database container. You can follow this tutorial, which says, you have to run
docker run --name=mysql1 -d mysql/mysql-server:tag
but there is the persistent volume missing. If you try this one, you are on the right way:
docker run --name mysqldb --volumes-from mysql_data -v /var/lib/mysql:/var/l
ib/mysql -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL
_ROOT_PASSWORD=supersecret -it -p 3306:3306 mysql
The problem is, that you have to create a container, mysql_data which contains a volume.

What about running a mysql database just with a volume?

First idea is to create a docker volume:

alpine:~#  docker volume create mysql_data
mysql_data
alpine:~# docker volume ls
DRIVER              VOLUME NAME
local               mysql_data
 And then start the mysql database:
 alpine:~# docker run --name mysqldb  -v mysql_data:/var/lib/mysql -e MYSQL_USER=mysql
-e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -i
t -p 3306:3306 mysql

Initializing database
2017-12-10T12:25:38.890958Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-10T12:25:39.114910Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-12-10T12:25:39.192006Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-10T12:25:39.269224Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3b5276c6-dda5-11e7-847f-0242ac110002.
2017-12-10T12:25:39.293895Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-12-10T12:25:39.296705Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2017-12-10T12:25:39.734384Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.734823Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.735089Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.735325Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.735530Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.735734Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.735969Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:39.736171Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
Database initialized
Initializing certificates
Generating a 2048 bit RSA private key
............+++
...........................................................................................................................................................................................................+++
unable to write 'random state'
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.......................+++
.......+++
unable to write 'random state'
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.......................+++
.............+++
unable to write 'random state'
writing new private key to 'client-key.pem'
-----
Certificates initialized
MySQL init process in progress...
2017-12-10T12:25:42.948452Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-10T12:25:42.949739Z 0 [Note] mysqld (mysqld 5.7.20) starting as process 87 ...
2017-12-10T12:25:42.952799Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-12-10T12:25:42.953188Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-10T12:25:42.953550Z 0 [Note] InnoDB: Uses event mutexes
2017-12-10T12:25:42.953828Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-12-10T12:25:42.954120Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-10T12:25:42.954451Z 0 [Note] InnoDB: Using Linux native AIO
2017-12-10T12:25:42.954900Z 0 [Note] InnoDB: Number of pools: 1
2017-12-10T12:25:42.955173Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-12-10T12:25:42.956841Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-12-10T12:25:42.965639Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-12-10T12:25:42.969568Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-12-10T12:25:42.982838Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-10T12:25:43.001695Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-12-10T12:25:43.002427Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-12-10T12:25:43.028474Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-12-10T12:25:43.029519Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-12-10T12:25:43.029785Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-12-10T12:25:43.030165Z 0 [Note] InnoDB: Waiting for purge to start
2017-12-10T12:25:43.080873Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 2565377
2017-12-10T12:25:43.085057Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-12-10T12:25:43.097783Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2017-12-10T12:25:43.111653Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2017-12-10T12:25:43.112695Z 0 [Warning] CA certificate ca.pem is self signed.
2017-12-10T12:25:43.112387Z 0 [Note] InnoDB: Buffer pool(s) load completed at 171210 12:25:43
2017-12-10T12:25:43.122126Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.122654Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.122922Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.123172Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.123424Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.123655Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.125278Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.125625Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:43.130811Z 0 [Note] Event Scheduler: Loaded 0 events
2017-12-10T12:25:43.131463Z 0 [Note] mysqld: ready for connections.
Version: '5.7.20'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
2017-12-10T12:25:43.131789Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2017-12-10T12:25:43.132034Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-12-10T12:25:43.141674Z 0 [Note] End of list of non-natively partitioned tables
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
2017-12-10T12:25:45.325153Z 5 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.326169Z 5 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.326766Z 5 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.327430Z 5 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.328439Z 5 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.329236Z 5 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.330139Z 5 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.330625Z 5 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
2017-12-10T12:25:45.355944Z 9 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.356363Z 9 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.356743Z 9 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.357080Z 9 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.357407Z 9 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.358138Z 9 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.358579Z 9 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:45.358825Z 9 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.

2017-12-10T12:25:45.360088Z 0 [Note] Giving 0 client threads a chance to die gracefully
2017-12-10T12:25:45.360365Z 0 [Note] Shutting down slave threads
2017-12-10T12:25:45.360562Z 0 [Note] Forcefully disconnecting 0 remaining clients
2017-12-10T12:25:45.360757Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2017-12-10T12:25:45.360982Z 0 [Note] Binlog end
2017-12-10T12:25:45.361681Z 0 [Note] Shutting down plugin 'ngram'
2017-12-10T12:25:45.361897Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2017-12-10T12:25:45.362098Z 0 [Note] Shutting down plugin 'partition'
2017-12-10T12:25:45.362285Z 0 [Note] Shutting down plugin 'ARCHIVE'
2017-12-10T12:25:45.362470Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2017-12-10T12:25:45.362653Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2017-12-10T12:25:45.362844Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2017-12-10T12:25:45.363019Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2017-12-10T12:25:45.363206Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2017-12-10T12:25:45.363455Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2017-12-10T12:25:45.363740Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2017-12-10T12:25:45.364038Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2017-12-10T12:25:45.364313Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2017-12-10T12:25:45.364603Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2017-12-10T12:25:45.364886Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2017-12-10T12:25:45.365129Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2017-12-10T12:25:45.365333Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2017-12-10T12:25:45.365507Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2017-12-10T12:25:45.365678Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2017-12-10T12:25:45.365846Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2017-12-10T12:25:45.366026Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2017-12-10T12:25:45.366214Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2017-12-10T12:25:45.366413Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2017-12-10T12:25:45.366616Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2017-12-10T12:25:45.366799Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2017-12-10T12:25:45.366976Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2017-12-10T12:25:45.367142Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2017-12-10T12:25:45.367305Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2017-12-10T12:25:45.367467Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2017-12-10T12:25:45.367628Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2017-12-10T12:25:45.367796Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2017-12-10T12:25:45.367978Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2017-12-10T12:25:45.368141Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2017-12-10T12:25:45.368307Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2017-12-10T12:25:45.368469Z 0 [Note] Shutting down plugin 'InnoDB'
2017-12-10T12:25:45.368926Z 0 [Note] InnoDB: FTS optimize thread exiting.
2017-12-10T12:25:45.369212Z 0 [Note] InnoDB: Starting shutdown...
2017-12-10T12:25:45.469927Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2017-12-10T12:25:45.471353Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 171210 12:25:45
2017-12-10T12:25:47.118138Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12169663
2017-12-10T12:25:47.125477Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2017-12-10T12:25:47.126721Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2017-12-10T12:25:47.127496Z 0 [Note] Shutting down plugin 'MyISAM'
2017-12-10T12:25:47.128253Z 0 [Note] Shutting down plugin 'CSV'
2017-12-10T12:25:47.128958Z 0 [Note] Shutting down plugin 'MEMORY'
2017-12-10T12:25:47.129665Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-12-10T12:25:47.130679Z 0 [Note] Shutting down plugin 'sha256_password'
2017-12-10T12:25:47.131807Z 0 [Note] Shutting down plugin 'mysql_native_password'
2017-12-10T12:25:47.132756Z 0 [Note] Shutting down plugin 'binlog'
2017-12-10T12:25:47.135910Z 0 [Note] mysqld: Shutdown complete


MySQL init process done. Ready for start up.

2017-12-10T12:25:47.379637Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-10T12:25:47.381062Z 0 [Note] mysqld (mysqld 5.7.20) starting as process 1 ...
2017-12-10T12:25:47.383987Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-12-10T12:25:47.384373Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-10T12:25:47.384612Z 0 [Note] InnoDB: Uses event mutexes
2017-12-10T12:25:47.384828Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-12-10T12:25:47.385024Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-10T12:25:47.385229Z 0 [Note] InnoDB: Using Linux native AIO
2017-12-10T12:25:47.385591Z 0 [Note] InnoDB: Number of pools: 1
2017-12-10T12:25:47.385887Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-12-10T12:25:47.387049Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-12-10T12:25:47.393069Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-12-10T12:25:47.395207Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-12-10T12:25:47.406539Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-10T12:25:47.417533Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-12-10T12:25:47.418058Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-12-10T12:25:47.433202Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-12-10T12:25:47.434200Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-12-10T12:25:47.434456Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-12-10T12:25:47.434855Z 0 [Note] InnoDB: Waiting for purge to start
2017-12-10T12:25:47.485468Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 12169663
2017-12-10T12:25:47.487084Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-12-10T12:25:47.500417Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2017-12-10T12:25:47.502089Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2017-12-10T12:25:47.511981Z 0 [Warning] CA certificate ca.pem is self signed.
2017-12-10T12:25:47.516700Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2017-12-10T12:25:47.517640Z 0 [Note] IPv6 is available.
2017-12-10T12:25:47.518010Z 0 [Note]   - '::' resolves to '::';
2017-12-10T12:25:47.518467Z 0 [Note] Server socket created on IP: '::'.
2017-12-10T12:25:47.523590Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.524079Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.524350Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.524623Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.524854Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.525118Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.527817Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.528270Z 0 [Note] InnoDB: Buffer pool(s) load completed at 171210 12:25:47
2017-12-10T12:25:47.528542Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-12-10T12:25:47.532739Z 0 [Note] Event Scheduler: Loaded 0 events
2017-12-10T12:25:47.533402Z 0 [Note] mysqld: ready for connections.
Version: '5.7.20'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
2017-12-10T12:25:47.533772Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2017-12-10T12:25:47.534079Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-12-10T12:25:47.541968Z 0 [Note] End of list of non-natively partitioned tables
and everything works like expected:
alpine:~# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
a6d0d908f034        mysql               "docker-entrypoint..."   3 minutes ago       Up 3 minutes        0.0.0.0:3306->3306/tcp   mysqldb
alpine:~# docker exec -it a6d0d908f034  mysql -u root -psupersecret
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> exit
Bye
If i create the following:
mysql> create database mydb;
Query OK, 1 row affected (0.00 sec)
mysql> use mydb
Database changed
mysql> create table mytable ( id int);
Query OK, 0 rows affected (0.03 sec)
and inside the volume:
alpine:/# docker volume inspect mysql_data
[
    {
        "CreatedAt": "2017-12-10T12:30:53Z",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/mysql_data/_data",
        "Name": "mysql_data",
        "Options": {},
        "Scope": "local"
    }
]
alpine:/# ls -l /var/lib/docker/volumes/mysql_data/_data/mydb/
total 112
-rw-r-----    1 999      ping            65 Dec 10 12:30 db.opt
-rw-r-----    1 999      ping          8556 Dec 10 12:31 mytable.frm
-rw-r-----    1 999      ping         98304 Dec 10 12:31 mytable.ibd
But after stopping the mysql database, i got the following on the next start:

alpine:~# docker run --name mysqldb  -v mysql_data:/var/lib/mysql -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -it -p 3306:3306 mysq
l
docker: Error response from daemon: Conflict. The container name "/mysqldb" is already in use by container "a6d0d908f03466181682666affb390650179c322f2848d32f2c72fab828f980c". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
 OK. I have to change the "--name" (--> mysqldb2):
alpine:/# docker exec -it mysqldb2  mysql -u root -psupersecret
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mydb               |
| mysql              |
| performance_schema |
| sample             |
| sys                |
+--------------------+
6 rows in set (0.01 sec)
Yippie! The data is still there!







Shortcomings of this approach:
  • Each time you start the mysql database on a new host, you have to run "docker volume create..."
    If you create a container with this volume (s. here oder there) you can skip this "docker volume create".
  • Both approaches will not work on docker swarm. The data is local to a node and not shared. One idea: Use a NFS mountpoint to redistribute the volume to all nodes.

Related posts:

Dec 30, 2017

Docker-Swarm: Running with more than one manager-node / How to add a secondary manager or multiple managers

Adding additional masters to a docker swarm is very easy. I just followed the documentation:

On the manager i ran the following command:
alpine:~# docker swarm join-token manager
To add a manager to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-3b7f69d3wgty0u68oab8724z07fkyvgc0w8j37ng1l7jsmbghl-5nrni6ksqnkljvqpp59m5gfh1 192.168.178.46:2377
And on the node:
node03:~# docker swarm join --token SWMTKN-1-3b7f69d3wgty0u68oab8724z07fkyvgc0w8j37ng1
l7jsmbghl-5nrni6ksqnkljvqpp59m5gfh1 192.168.178.46:2377

This node joined a swarm as a manager.
The new state of the cluster shows:
alpine:~# docker  info | grep -A 23 Swarm
Swarm: active
 NodeID: wy1z8jxmr1cyupdqgkm6lxhe2
 Is Manager: true
 ClusterID: wkbjyxbcuohgdqc3amhl9umlq
 Managers: 2
 Nodes: 4

 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 192.168.178.46
 Manager Addresses:
  192.168.178.46:2377
  192.168.178.50:2377
If you want to use a new token just run:
alpine:~# docker  swarm join-token --rotate  manager
Successfully rotated manager join token.

To add a manager to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-3b7f69d3wgty0u68oab8724z07fkyvgc0w8j37ng1l7jsmbghl-cgy143mwghbfoozt0b8li2587 192.168.178.46:2377

Related posts:

Dec 13, 2017

Docker-CE: Setting up a tomcat in less than a minute and running your JSP...

Last time i wrote about processes and files of a docker container hosting the docker example myapp.py.
Next step was to run a tomcat with a small application inside.

This can be done with theses commands:
  1. Get tomcat from the docker library:
    # docker pull tomcat
    Using default tag: latest
    latest: Pulling from library/tomcat
    3e17c6eae66c: Pull complete
    fdfb54153de7: Pull complete
    a4ca6e73242a: Pull complete
    5161d2a139e2: Pull complete
    7659b327f9ec: Pull complete
    ce47e69f11ad: Pull complete
    7d946df3a3d8: Pull complete
    a57cba73d797: Pull complete
    7e6f56cdb523: Pull complete
    06e4787b3ca5: Pull complete
    c760cb7e43cb: Pull complete
    ad6d0815df5c: Pull complete
    d7e1da09fc22: Pull complete
    Digest: sha256:a069d49c414bad0d98f5a4d7f9b7fdd318ccc451dc535084480c8aead68272d2
    Status: Downloaded newer image for tomcat:latest
  2. Test the tomcat:
    # docker run -p 4000:8080 tomcat
    20-Nov-2017 20:38:11.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.23
    20-Nov-2017 20:38:11.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Sep 28 2017 10:30:11 UTC
    20-Nov-2017 20:38:11.762 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.23.0
    ....
    ....
    org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
    20-Nov-2017 20:41:59.928 INFO [Thread-5] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
     

This was easy.
Now create your JSP and run it:
  1. create a directory
    mkdir tomcatstatus
  2. create a jsp inside this direcotry
    vi tomcatstatus/index.jsp
    and insert the following content:
    <%@ page language="java" import="java.util.*" %>


    Host name : <%=java.net.InetAddress.getLocalHost().getHostName() %>

    Server Version: <%= application.getServerInfo() %>

    Servlet Version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion(
    ) %>
    JSP Version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersio
    n() %>
  3. Run docker
    docker run -v /home/schroff/tomcatstatus:/usr/local/tomcat/webapps/status -p 4000:8080 tomcat
  4. Connect to port 4000:

Wow - i am really stunned how fast the tomcat was setup and the jsp was launched. No installation of java (ok, this is only apt install) and no setup procedure for Apache tomcat (ok, this is just a tar -zxvf). But if i want to run more than one installation - docker is faster than repeating the installation or copying files.  Really cool!


(One thing i forgot: Installation of docker onto your server)

Related posts:

Dec 10, 2017

Docker-Swarm: Running a minimal webserver in a swarm

In my last posting to docker swarm i created a swarm on virtualbox with alpine linux with a hdd footprint of 290MB per node:
There are some tutorials out there with running a nginx or a java webserver in a container but >100MB for each node seems far to much for my tests.

So i decided to create a application which listens on port 8080 with netcat. I created a directory ncweb with ncweb.sh:
ncweb# cat ncweb.sh
#!/bin/bash
sed -i  's/Hostname:.*/Hostname: '$HOSTNAME'/g' index.html
while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat index.html;}  | nc  -l -p 8080; done 2&>1 >> logfile
and a index.html:
ncweb# cat index.html
<html>
  <head>
    <title>"Hello, World"</title>
  </head>
  <body bgcolor=white>
    <table border="0" cellpadding="10">
      <tr>
        <td>
          <h1>"Hello, World"</h1>
        </td>
      </tr>
    </table>
  </body>
</html>
The Dockerfile looks like this:
# cat Dockerfile
FROM alpine
WORKDIR /tmp
ADD .  /tmp
ENTRYPOINT [ "/tmp/ncweb.sh" ]
After that i created the container:
ncweb# docker build -t ncweb:0.2 .
Sending build context to Docker daemon  4.096kB
Step 1/5 : FROM alpine
 ---> 053cde6e8953
Step 2/5 : WORKDIR /tmp
 ---> Using cache
 ---> c3e11ac3773b
Step 3/5 : RUN mkdir ncweb
 ---> Using cache
 ---> d9e634c03cd1
Step 4/5 : ADD .  /tmp
 ---> 95f022aacc1c
Step 5/5 : ENTRYPOINT [ "/tmp/ncweb.sh" ]
 ---> Running in c1a9e8cee248
 ---> 6880521f68e4
Removing intermediate container c1a9e8cee248
Successfully built 6880521f68e4
Successfully tagged ncweb:0.2
And let's do a test without docker swarm:
ncweb# docker run -p 8080:8080  ncweb
But running this as a service fails:
# docker service create --replicas=1 --name myweb ncweb:0.2
image ncweb:0.2 could not be accessed on a registry to record
its digest. Each node will access ncweb:0.2 independently,
possibly leading to different nodes running different
versions of the image.
n0himwum38bqzd8ob1vf8zhip
overall progress: 0 out of 1 tasks
1/1: No such image: ncweb:0.2
^COperation continuing in background.
Use `docker service ps n0himwum38bqzd8ob1vf8zhip` to check progress.
and:
# docker service ps n0himwum38bqzd8ob1vf8zhip
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                 ERROR                        PORTS
8tjsuae9jv8o        myweb.1             ncweb:0.2           node01              Ready               Rejected 3 seconds ago        "No such image: ncweb:0.2"  
qp24ssxb5bl5         \_ myweb.1         ncweb:0.2           alpine              Shutdown            Failed 36 seconds ago         "task: non-zero exit (2)"   
zwfgcatk7zyi         \_ myweb.1         ncweb:0.2           node01              Shutdown            Rejected about a minute ago   "No such image: ncweb:0.2"  
v4a7zkb85yd4         \_ myweb.1         ncweb:0.2           node01              Shutdown            Rejected about a minute ago   "No such image: ncweb:0.2"  
ycjftjusv484         \_ myweb.1         ncweb:0.2           node01              Shutdown            Rejected about a minute ago   "No such image: ncweb:0.2"  
 
# docker service rm n0himwum38bqzd8ob1vf8zhip
n0himwum38bqzd8ob1vf8zhip
The error "No such image..." is happening, because the container ncweb is only in the repository of my master.
The easiest way for my test environment is to distribute the local image to all nodes:
# docker save ncweb:0.3 | ssh 192.168.178.47 docker load
The authenticity of host '192.168.178.47 (192.168.178.47)' can't be established.
ECDSA key fingerprint is SHA256:2/8O/SE1fGJ4f5bAQls5txrKMbqZfMmiZ+Tha/WFKxA.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.178.47' (ECDSA) to the list of known hosts.
root@192.168.178.47's password:
Loaded image: ncweb:0.3
(i have to distribute a ssh-key to all nodes)

and then:
alpine:~/ncweb# docker service create --replicas=1 --name myweb ncweb:0.3
image ncweb:0.3 could not be accessed on a registry to record
its digest. Each node will access ncweb:0.3 independently,
possibly leading to different nodes running different
versions of the image.
# docker service ps myweb
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
in97xlc7azcw        myweb.1             ncweb:0.3           node01              Running             Running 8 seconds ago      
So my nc-webserver runs on node01, but i can not access it there because i did not define any port mappings ;-(

But finally this command did the job:
# docker service create --replicas=1 --name myweb --publish 8080:8080  ncweb:0.3
image ncweb:0.3 could not be accessed on a registry to record
its digest. Each node will access ncweb:0.3 independently,
possibly leading to different nodes running different
versions of the image.
runf8u9r8719sk13mkf8hh8ec
overall progress: 1 out of 1 tasks
1/1: running  
verify: Service converged
The hostname corresponds to the docker container id on node01:
node01:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
6c9434b08082        ncweb:0.3           "/tmp/ncweb.sh"     37 minutes ago      Up 37 minutes                           myweb.1.lqiyb34cuxxme2141ahsg8neu


Remaining open points:
  • Is it possible to do a failback or limit the number of a service per node?
  • How to get a loadbalancing mechanism for a server application?
    (load balancer needed?)
  • What happens, if the manager fails / is shutdown?

Related posts:




Dec 5, 2017

Docker-Swarm: One manager, two nodes with Alpine Linux

After creating a Alpine Linux VM inside virtualbox and after adding docker because of the small disk footprint (Alpine Linux: 170MB | with docker: 280MB) i performed the following steps to create a docker swarm:
  • cloning the vm twice
  • assigning a static ip to the manager node
  • create new MACs for the network interface cards on the nodes 


Then i followed the tutorial https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/ but without running the docker-machine commands, because i have 3 VMs and do not want to run the node on top of docker.

manager:
alpine:~# docker swarm init --advertise-addr 192.168.178.46
Swarm initialized: current node (wy1z8jxmr1cyupdqgkm6lxhe2) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-3b7f69d3wgty0u68oab8724z07fkyvgc0w8j37ng1l7jsmbghl-0yfr1eu5u66z8pinweisltmci 192.168.178.46:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
nodes
#     docker swarm join --token SWMTKN-1-3b7f69d3wgty0u68oab8724z07fkyvgc0w
8j37ng1l7jsmbghl-0yfr1eu5u66z8pinweisltmci 192.168.178.46:2377
This node joined a swarm as a worker.

And then a check on the master:
alpine:~# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
wy1z8jxmr1cyupdqgkm6lxhe2 *   alpine              Ready               Active              Leader
pusf5o5buetjqrsmx3kzusbyt     node01              Ready               Active             
io3z3b6nf8xbzkyzjq6sa7cuc     node02              Ready               Active             
Run a first job:
alpine:~# docker service create --replicas 1 --name helloworld alpine ping 192.168.178.1
rsn6igby4f6d7uuy8eny7sbfb
overall progress: 1 out of 1 tasks
1/1: running  
verify: Service converged
But on my manager i get no output for "docker ps". But this is, because the service is not running here:
alpine:~# docker service ps helloworld
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
wrrobalt4oe7        helloworld.1        alpine:latest       node01              Running             Running 2 minutes ago                      
Node 1 shows:
node01:~# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
40c5e9b2ffbc        alpine:latest       "ping 192.168.178.1"   3 minutes ago       Up 3 minutes                            helloworld.1.wrrobalt4oe7mrbhxjlweuxgk
If i do a kill on the ping process, it is immediately restarted:
node01:~# ps aux|grep ping
 2457 root       0:00 ping 192.168.178.1
 2597 root       0:00 grep ping
node01:~# kill 2597
node01:~# ps aux|grep ping
 2457 root       0:00 ping 192.168.178.1
 2600 root       0:00 grep ping

A scale up is no problem:
alpine:~# docker service create --replicas 2 --name helloworld alpine ping 192.168.178.1
3lrdqdpjuqml6creswdcqpn2p
overall progress: 2 out of 2 tasks
1/2: running   [==================================================>]
2/2: running   [==================================================>]
verify: Service converged
alpine:~# docker service ps helloworld
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
616scw68s8bv        helloworld.1        alpine:latest       node02              Running             Running 8 seconds ago                      
n8ovvsw0m4id        helloworld.2        alpine:latest       node01              Running             Running 8 seconds ago                      
And a shutdown of node02 is no problem:
alpine:~# docker service ps helloworld
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS
bne2enbkabfo        helloworld.1        alpine:latest       alpine              Ready               Ready 2 seconds ago                             
616scw68s8bv         \_ helloworld.1    alpine:latest       node02              Shutdown            Running 17 seconds ago                          
n8ovvsw0m4id        helloworld.2        alpine:latest       node01              Running             Running about a minute ago          


After a switchoff of node01 both service are running on the remaining master:
alpine:~# docker service ps helloworld
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                ERROR               PORTS
bne2enbkabfo        helloworld.1        alpine:latest       alpine              Running             Running about a minute ago                      
616scw68s8bv         \_ helloworld.1    alpine:latest       node02              Shutdown            Running about a minute ago                      
pd8dfp4133yw        helloworld.2        alpine:latest       alpine              Running             Running 2 seconds ago                           
n8ovvsw0m4id         \_ helloworld.2    alpine:latest       node01              Shutdown            Running 2 minutes ago              
So failover is working.
But failback does not occur. After switching on node01 again, the service remains on the manager:
alpine:~# docker service ps helloworld
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE               ERROR                         PORTS
bne2enbkabfo        helloworld.1        alpine:latest       alpine              Running             Running 4 minutes ago                                    
616scw68s8bv         \_ helloworld.1    alpine:latest       node02              Shutdown            Running 4 minutes ago                                    
pd8dfp4133yw        helloworld.2        alpine:latest       alpine              Running             Running 2 minutes ago                                    
n8ovvsw0m4id         \_ helloworld.2    alpine:latest       node01              Shutdown            Failed about a minute ago   "task: non-zero exit (255)"  
alpine:~# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
wy1z8jxmr1cyupdqgkm6lxhe2 *   alpine              Ready               Active              Leader
pusf5o5buetjqrsmx3kzusbyt     node01              Ready               Active             
io3z3b6nf8xbzkyzjq6sa7cuc     node02              Down                Active             


Last thing: How to stop the service?
alpine:~# docker service rm  helloworld
helloworld
alpine:~# docker service ps helloworld
no such service: helloworld

Remaining open points:
  • Is it possible to do a failback or limit the number of a service per node?
  • How to do this with a server application?
    (load balancer needed?)
  • What happens, if the manager fails / is shutdown?
Related posts: