0

Start Docker Daemon

docker daemon -g /u01/docker

Docker Info

[bu@bu ~]$ docker version
Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        
 OS/Arch:      linux/amd64

Dockerfile

FROM nginxmagento

MAINTAINER Bilal

ENTRYPOINT service ssh restart && service nginx restart && service mysql restart && service cron restart && service php7.0-fpm restart && bash

Build Image

docker build -t magento .   

Create Container

docker run -it -d --name magento -h host.name -v /u01/Bilal/test/_data:/var/www/html -p 3020:80 --net mynetwork --ip 172.18.0.51 --privileged magento   

It successfully start service in ENTRYPOINT but it randomly shutdown the docker daemon, In docker daemon too no error thrown it just exit from terminal. I searched docker daemon log file by find linux command and this link but I can't find where it is located.

please give suggestions about why it is behave like this?

If I follow any bad practice, please mention?

Community
  • 1
  • 1
Bilal Usean
  • 2,322
  • 3
  • 22
  • 45
  • You use the container as if it was a virtual machine starting a number of services in it, see [best practices of docker](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/each-container-should-have-only-one-concern). One of the downsides: you're unable to scale or update your database independently from you web server. Furthermore, it is discouraged having a SSH daemon in the container. You can use `docker exec -it $CONTAINER_ID bash` to get a bash session in your container. – fzgregor Feb 23 '17 at 07:28
  • we have 10 containers, it is local staging setup. Before that I start service from docker exec -it ...... . But it will take huge amount time to set everything so we planned like start container and their default services while daemon start. – Bilal Usean Feb 23 '17 at 07:32
  • 1
    Have a look into [docker-compose](https://docs.docker.com/compose/overview/). There you have one compose file that describes multiple containers and you can start and stop them all at once and you can scale individual containers. – fzgregor Feb 23 '17 at 07:37
  • You should really read more about best practices in Docker. Not only the part about "one concern per container" as pointed out already. There's a lot to improve in your Dockerfile, the way you run the daemon and the way you start the container. – Alexander Block Feb 23 '17 at 07:40
  • I don't felt anything wrong with docker daemon start & docker run. Default docker directory is /var/lib/docker so I run docker daemon to point /u01/docker. Also docker file just have entrypoints only because already all the needed services are installed so point my existing image with entrypoints. @AlexanderBlock am I wrong? – Bilal Usean Feb 23 '17 at 07:50
  • 2
    Just a few problems I see: 1. You don't use systemd or something comparable to run the daemon. 2. You don't follow the "single concern" principle. 3. You start the container with "--privileged". 4. You provide custom network options instead of trusting in Docker doing it. 5. You misuse the ENTRYPOINT (it looks like you wanted CMD...or use a script in-between). 6. Your container will probably just exit after service startup (you use bash without arguments). 7. You mix "-it" with "-d". There are probably more and that's why you really should read through more documentation. – Alexander Block Feb 23 '17 at 07:56

0 Answers0