How to retain docker alpine container after “exit” is used?

前端 未结 5 552
栀梦
栀梦 2020-12-30 05:04

Like for example if I use command docker run -it alpine /bin/sh it starts a terminal after which I can install packages and all. Now when I use exit

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 05:55

    You should use docker start, which allows you to start a stopped container. If you didn't name your container, you'll need to get it's name/id using docker ps.

    For example,

    $docker ps
    CONTAINER ID        IMAGE                        COMMAND
    4c01db0b339c        alpine                       bash    
    
    $docker start -i -a 4c01db0b339c   
    

提交回复
热议问题