CentOS 7 docker container with Perl/Mojolicious

Requirements:

  1.  A running/live docker installation
  2. An open/available port on the host to access the newly installed container (4003 in this example)
  3. A basic understanding of docker containerization technology.

I ran into a network problem. A simple restart of docker service fixed it.

[root@ns24 ~]#docker run -d –publish 4003:80 a2zdotblue/c7-systemd-perl-mojo-02

Digest: sha256:a6a808fd286b1af1aa5ee46d5fa2eac2b61b02ecff234101bd098596a3b2a1f4
Status: Downloaded newer image for docker.io/a2zdotblue/c7-systemd-perl-mojo-02:latest
f07bfaab03efc10ceed140c04238746a4ba5edb54c01bb22b7af95648a38260c
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint lucid_swirles (d240ed06c8cb4f3a366e53acf1554ec6b437e296659f53646e8ad08f1e0c7129): (iptables failed: iptables –wait -t nat -A DOCKER -p tcp -d 0/0 –dport 4003 -j DNAT –to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).

[root@ns24 ~]# service docker restart


Redirecting to /bin/systemctl restart docker.service

Rerun code after docker restart

[root@ns24 ~] # docker run -d –publish 4003:80 a2zdotblue/c7-systemd-perl-mojo-02


cc422a9d647e71478ace6bb9a7e48b5034f66cc2142c830ebc0381469a92a34f

Log into the Container:

[root@ns24 ~]# docker exec -it cc422a9d647e /bin/bash

[root@cc422a9d647e app]

The Mojolicious sample app uses port 80 inside the container. Run hypnotoad (yes, already installed inside the container along with Mojoloicious Web Framework)

In docker terminology, port 80 is exposed for this app.

[root@cc422a9d647e app]# hypnotoad perlmojo/script/perlmojo


[Thu Aug 16 15:01:46 2018] [info] Listening at “http://*:80”
Server available at http://127.0.0.1:80

The above output confirms that the app is working and you can always update the app by logging into the live container!

Actually this example is live at ns24.a1z.us. It is accessible as long as my ISP provides/maintains good connection or until I decide to take it down!

Leave a Reply

Your email address will not be published. Required fields are marked *