How to save a docker container and run it?

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 -ait shows the status that came out. I just want to save this container and run so that I can ssh into this container and probably transfer files and so on. It seems that containers are mainly used to start servers, am I right?

+4
source share
2 answers

you can at least save your container with something like docker run -d hello sleep infinity, but, as Rene M said, you should put in your Dockerfile something that needs to be done in CMD or ENTRYPOINT, see the document

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

and

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

+4

. . , , .

:

  • tty. , tty, - , . , , . . , .

docker run -i -t -name hello dockerfile

  1. - . CMD , . , CMD. , .
+3

All Articles