2

I am using the below command in the dockerfile to automatically start mysql on docker run:

ENTRYPOINT service mysql start && bash

The above command is working fine in some system but not in all. I also have tried the below command but still facing the same issue.

EXPOSE 3306
CMD /etc/init.d/mysql start && \
    /bin/bash

I am getting the below error in some system:

* Starting MySQL database server mysqld                             [fail]

So can anyone please help me solve this issue. So that my docker container can run on all type of system where docker can be installed.

Arijit Panda
  • 1,581
  • 2
  • 17
  • 36

1 Answers1

0

First, it depends on your exact docker run command.
As commented here, you approach works with docker run -itd ...

Second, it depends on the host, which should be compatible with docker execution (ie, its kernel should be the right architecture, 64bits not 32, recent enough...)

The OP adds:

I am using docker run -it docker_image_name command to run the docker image and second system i.e. Linux corona2 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux its not working.

I have used 1.8.3 version to build my image and.
is it because of the community edition version as ce is written with 18.03.1-ce.

Then yes: make sure to use the same docker version for building and running (on both servers)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have used the same docker run command in two 64 bits architecture system. But only in one system its working. Here is the __uname -a__ output for both the system `Linux CG-Lab 3.16.0-71-generic #92~14.04.1-Ubuntu SMP Thu May 12 23:31:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux` `Linux corona2 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux` In first case, its working fine but in other its not. – Arijit Panda Jun 06 '18 at 05:24
  • What is your docker run command? And on the system which is not working, do you see any error message? What `docker ps -a` shows you? – VonC Jun 06 '18 at 05:29
  • I am using `docker run -it docker_image_name` command to run the docker image and second system i.e. `Linux corona2 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux` its not working. I have added the error message in the question. – Arijit Panda Jun 06 '18 at 05:45
  • @Arijit What a `docker logs` of the container shows you? And what version of docker are you using? – VonC Jun 06 '18 at 06:16
  • docker logs showing the same error as I mentioned in the question. In `Docker version 18.03.1-ce, build 9ee9f40`, my docker image is **not running** but in `Docker version 1.8.3, build f4bf5c7`, it's **running** – Arijit Panda Jun 06 '18 at 06:27
  • @Arijit 1.8.3 seems very old compared to 18.03... Is it a typo? – VonC Jun 06 '18 at 06:34
  • it's not typing mistake. I have used 1.8.3 version to build my image. is it because of the community edition version as `ce` is written with 18.03.1-ce. – Arijit Panda Jun 06 '18 at 06:44
  • I tried to ran my docker image on another system where the system version is `Linux STlab 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux` and docker version `Docker version 18.03.1-ce, build 9ee9f40`. My docker image is working fine without showing any error. That's why I feel the docker community edition version is not the issue. – Arijit Panda Jun 06 '18 at 07:07
  • @Arijit OK, I didn't realize that when reading your original question. Compare their PATH and environment variable: there should be a difference which can explain that. – VonC Jun 06 '18 at 07:45
  • I compared both but could not find any reason. This has become a strange issue for me. I have also installed same os and same docker version on another system. On the new system, my container is working fine. – Arijit Panda Jun 06 '18 at 08:37