Docker Community Forums

Share and learn in the Docker community.

Docker run issue

build

(Rtauxe) #1

Hi all,

I’m new with :whale2: and I’m facing an issue.

I wanted to deploy a “racktables” container and I want to do it by myself. So I used the official ubuntu docker image and I installed Apache, MySQL and PHP and configured racktables. Everything is working fine.

Here is my problem :
I commit the container to save it as an image. Now I have the image and want to run it again. When I run
docker run -d -p 8082:80 --name racktables racktables:latest

The container is initialized but keep restarting always and always.

And I don’t have any logs when I run
docker logs 783bc0198e58

Like I undestand while reading million of forum and documentation :tired_face: my container doesn’t have anything to run at startup. But I don’t know what to do for solving this issue.

Engine information :
Docker version 18.06.0-ce, build 0ffa825
OS :
Linux 4.15.0-29-generic #31-Ubuntu

Somebody can help me ? :smile:


(Martin Terp) #2

Hi :slight_smile:

This racktables image that you try to start from, is that somehting you build yourself?
Because typicaly, you wont start it with /bin/bash (as i can see in your screenshot that it does, but i belive its default )
So, my guess is that you need to run the container, with a command, like:

docker run -d -p 8082:80 --name racktables racktables:latest /some/command/to/start/racktables


(Rik) #3

Try running

docker run -d -p 8082:80 --name racktables racktables:latest /bin/bash

and start httpd from the command line with

httpd -DFOREGROUND

If that works do

docker run -d -p 8082:80 --name racktables racktables:latest httpd -DFOREGROUND


(Rtauxe) #4

Yes I took the ubuntu official image from docker hub and then installed LAMP and configured Racktables. When done, I commited the image.

So I tried what you said but it don’t work.
Basically I just created a script like this :

#!/bin/bash
service apache2 start
service mysql start
exit 0

Then I ran docker with this command :

docker run -d -p 8082:80 --name racktables_df racktables:201807274 /script/startrt.sh

That didn’t work, but I have a log now :

docker logs e2907758106a
standard_init_linux.go:190: exec user process caused "exec format error"

It’s not working. The container exit directly

And i don’t have any log like this.

Thank for your reply !


(Martin Terp) #5

Hi again.

You cant start services that way im afraid.

if you want to start multiple services within 1 container, you should look into Supervisor.

I wrote earlier an quick example of this:


(Rtauxe) #6

Ok so I’ll have a look for Supervisor.

Do you think that is better to run a container with php and apache and another with mysql ?

Thank you


(Martin Terp) #7

Yes that would be the docker way to do it :slight_smile:

php has a php+apache image


(Rtauxe) #8

So that what I need to do :

Using Dockefile

Create a MySQL container from a Dockerfile with settings that I want/need. Then create a Dockerfile from php+apache image with all commands needed to configure Racktables that I link to the MySQL container.

Using docker-compose

Create a stack that will create these two containers.

Sounds better with docker-compose. :sunglasses:

I’ll give a try, if needed I’ll post again on this topic.


(Martin Terp) #9

yes, always use docker-compose if you ask me :slight_smile:
Then you dont have to remember the “docker run” command :slight_smile:

Also, mysql allready have a image for mysql: https://hub.docker.com/_/mysql/


(Rik) #10

Sorry my bad it should be
docker run -ti -p 8082:80 --name racktables racktables:latest /bin/bash


(Mrdelorenzi) #11

Pictures of text, are hard to read by blind people. It is in infringement of accessibility laws. (This image is hard to read by me (gray on black, small size)). Therefore post text as text.