I created my first Dockerfile, but when i run the command
sudo docker ps
The container isn't running in the background, here's my dockerfile:
# Set the base image to Ubuntu
FROM debian:jessie
# File Author / Maintainer
MAINTAINER <Qop>
# Update the repository sources list
RUN apt-get update
################## BEGIN INSTALLATION ######################
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y \
vim \
apache2
##################### INSTALLATION END #####################
# Expose the default port
EXPOSE 81
# Default port to execute the entrypoint (MongoDB)
CMD ["--port 81"]
# Set default container command
ENTRYPOINT /bin/bash
With the bash
entrypoint, bash will exit as soon as stdin returns an end of file. So you leave it running, you need to start it with docker run -itd image-name
. The -i
makes it interactive, -t
assigns a tty, and -d
detaches. That keeps the stdin open on the container and allows you to attach or exec commands against the container.
Follow up: I just saw your command --port 81
which when run as a command on bash
will give you an invalid option. If you need to run mongo with that as an option, you'll need a different entry point.