I have docker image with Dockerfile
, that successfully build with docker build .
command. The Dockerfile
content is:
FROM ubuntu
RUN apt-get update && apt-get install -y nginx php5 php5-fpm
ADD . /code
How can I run my docker container to see that Nginx
is work?
UPDATE: When I try to use next Dockerfile:
FROM ubuntu
RUN apt-get update && apt-get install -y nginx php5 php5-fpm
RUN sudo echo "daemon off;" >> /etc/nginx/nginx.conf
CMD service php5-fpm start && nginx
It build successfully with docker build -t my/nginx .
, but when I enter docker run --rm -ti my/nginx
command, my terminal not response:
When you build the image you probably want to specify the image name with -t
option.
docker build -t my/nginx .
To run a container use the run
command
docker run --rm -ti my/nginx
You probably should add the following command to your Dockerfile
CMD ["nginx"]
Or with php5-fpm
CMD service php5-fpm start && nginx
UPDATE. You should run nginx as daemon off. Add the following to your Dockerfile after installing nginx.
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
Update2.
-ti
option in run allows you to check the log messages if any.
Usually you should run a container in background using -d
instead of -ti
.
You can attach to a running container using the attach
command.
You may also check docker reference to see how to stop and remove a container and other commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With