Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep the docker container up and running?

Tags:

docker

Here is my simple docker file

FROM java:8
EXPOSE 4000

now when I run it using the following command

sudo docker run --name hello dockerfile

and do docker ps -a it shows the status as exited. I just want to keep this container up and running so I can ssh into this container and probably transfer files and so on. It looks like containers are mainly used to run servers am I correct?

like image 659
user1870400 Avatar asked Feb 08 '23 07:02

user1870400


1 Answers

you can at least keep your container up with something like docker run -d hello sleep infinity but as said by René M, you should put in your Dockerfile something to do in your CMD or ENTRYPOINT, see the doc

https://docs.docker.com/engine/reference/builder/#cmd

and

https://docs.docker.com/engine/reference/builder/#entrypoint

like image 157
user2915097 Avatar answered Feb 13 '23 03:02

user2915097