I have installed docker for learning purposes on my Linux machine.
I am trying to make it work with nginx server i pulled but it only works under one condition (using no command)
I used “docker pull nginx” to try having a nginx server inside my docker,
after it pulled it I ran 4 tries only working with the first two.
docker run --name=nirel -it -v /var/www:/var/www -p 80:80 -d nginx (working)
*I now stopped the container and removed it and tried:
docker run --name=nirel -it -v /var/www:/var/www -p 80:80 nginx (also works)
*For both cases I saw they get a default command of nginx -g (and some text).
I also tried (after stopping the last one and deleting it):
docker run --name=nirel -it -v /var/www:/var/www -p 80:80 -d nginx /bin/bash (doesn’t work)
docker run --name=nirel -it -v /var/www:/var/www -p 80:80 nginx /bin/bash (doesn’t work)
so I have 2 questions:
I understand -d makes true for using the container as a daemon, but why
it works both with it and without it? what does the -d actually does?
2) why if I use a /bin/bash as the command it wont work?
i use /bin/bash and attach my container, then using service nginx start
it does work.But after I am exiting the container and starting it again
it doesn’t work again, and if I am attaching it i can see the service
(nginx) is stopped so why?
Thanks in advance,