Foreman docker plugin setup help

foreman-setup
ssl
docker

#1

TL;DR I was able to solve the problem while writing but decided to post anyway to contribute to documentation
Problem:
I successfully installed foreman_docker plugin and configured the docker API to listen on the network. In the containers tab, I can see the container that is curently running on my docker container host.

However, I can’t turn on containers from Foreman Web even though the UI responds with a confirmation. Indeed, even though I was able to create the container, it doesn’t show up when I issue docker container ls

upport@server1100:~$ docker container ls
CONTAINER ID        IMAGE                         COMMAND             CREATED             STATUS              PORTS                                                                                                                                                          NAMES
0e784db6c119        graphiteapp/graphite-statsd   "/sbin/my_init"     6 months ago        Up About an hour    0.0.0.0:2003-2004->2003-2004/tcp, 8080/tcp, 0.0.0.0:2023-2024->2023-2024/tcp, 0.0.0.0:8126->8126/tcp, 8125/tcp, 0.0.0.0:8125->8125/udp, 0.0.0.0:8081->80/tcp   graphite

Expected outcome:
Newly created container should be turned on after clicking “Power On”

Foreman and plugin versions:
image
Foreman: 1.19.1

Other relevant data:
I only found one relevant post but that was about accessing Docker API on HTTPS

I used the following links to configure docker and foreman:
https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
https://theforeman.org/plugins/foreman_docker/3.x/index.html

from /var/log/foreman/production

2019-02-07T14:28:50 [I|app|] Started PUT "/containers/1/power" for 10                                                                  .223.10.120 at 2019-02-07 14:28:50 +0100
2019-02-07T14:28:50 [I|app|f32f9] Processing by ContainersController#                                                                  power as HTML
2019-02-07T14:28:50 [I|app|f32f9]   Parameters: {"authenticity_token"                                                                  =>"rW6/Em+ZZlnfR031F/nnwdXw7L1ctazoU38JDQP4mNrwwDL8EUCUym1ouYW86w/Cjs                                                                  WUhGOj+DtEml9E5lrUVg==", "id"=>"1"}
2019-02-07T14:28:50 [I|app|f32f9] Current user set to admin (admin)
2019-02-07T14:28:52 [I|app|f32f9] Redirected to https://server0142.cs                                                                  .technik.fhnw.ch/containers?id=1
2019-02-07T14:28:52 [I|app|f32f9] Completed 302 Found in 2046ms (Acti                                                                  veRecord: 1.5ms)
2019-02-07T14:28:52 [I|app|] Started GET "/containers?id=1" for 10.22                                                                  3.10.120 at 2019-02-07 14:28:52 +0100
2019-02-07T14:28:52 [I|app|542b1] Processing by ContainersController#                                                                  index as HTML
2019-02-07T14:28:52 [I|app|542b1]   Parameters: {"id"=>"1"}
2019-02-07T14:28:52 [I|app|542b1] Current user set to admin (admin)
2019-02-07T14:28:52 [I|app|542b1]   Rendering vendor/ruby/2.3.0/gems/                                                                  foreman_docker-4.1.0/app/views/containers/index.html.erb within layou

Epilogue

I discovered that even if I run a docker container on the docker host the container don’t appear in “docker ps”. With “docker ps -a” suddenly the containers appeared and with them more information why the werent visible (see status):

support@server1100:~$ docker ps -a
CONTAINER ID        IMAGE                         COMMAND             CREATED             STATUS                      PORTS                                                                                                                                                          NAMES
b6306b55a6ea        fauria/lamp                   "bash"              3 minutes ago       Exited (0) 3 minutes ago                                                                                                                                                                   elated_lalande
bc2662abc579        fauria/lamp                   "bash"              4 minutes ago       Exited (0) 4 minutes ago                                                                                                                                                                   nifty_swanson
b6fc3c191bd1        ubuntu:latest                 "/bin/bash"         22 minutes ago      Exited (0) 19 minutes ago                                                                                                                                                                  tset
0e784db6c119        graphiteapp/graphite-statsd   "/sbin/my_init"     6 months ago        Up About an hour            0.0.0.0:2003-2004->2003-2004/tcp, 8080/tcp, 0.0.0.0:2023-2024->2023-2024/tcp, 0.0.0.0:8126->8126/tcp, 8125/tcp, 0.0.0.0:8125->8125/udp, 0.0.0.0:8081->80/tcp   graphite

They were in Exited state!

Turned out, that I overlooked a checkbox that requires starting the container. Note: This is not included in the docs, they are out-dated!

Result

Nice!

$ docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                                                                                                                                          NAMES
2cee4dc74de0        fauria/lamp:latest            "/usr/sbin/run-lamp.…"   59 seconds ago      Up 57 seconds       80/tcp, 3306/tcp                                                                                                                                               test-lamp

#2

Looks like indeed we are missing update documentation for Foreman Docker plugin version 4.1, would you like to contribute to it? The manual is on github at https://github.com/theforeman/theforeman.org/tree/gh-pages/plugins/foreman_docker and pull requests are welcome!


#3

Hi @tbrisker I’d love to contribute! Stay tuned for my pull request


#4

Submitted the PR and also created a Redmine issue. Feel free to add comments.