How to show the run command of a docker container

前端 未结 11 1215
萌比男神i
萌比男神i 2020-11-27 10:24

I use a third party GUI (Synology Docker package) to setup a docker container. However, it\'s limitation makes me need to run the container from the command line. (I want to

11条回答
  •  有刺的猬
    2020-11-27 10:47

    I wrote a simple Node-based CLI tool to generate a docker run command from an existing container.

    https://www.npmjs.com/package/rekcod

    Here's an example:

    $ npm i -g rekcod
    $ rekcod redis_container
    
    docker run -d --name redis_container --restart always -h a44159e148e1 \
    --expose 6379/tcp -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    -e REDIS_VERSION=3.0.7 -e REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-3.0.7.tar.gz \
    -e REDIS_DOWNLOAD_SHA1=e56b4b7e033ae8dbf311f9191cf6fdf3ae974d1c \
    --entrypoint "/entrypoint.sh" redis "redis-server"
    

    Also handles links and mounted volumes and other stuff.

    Not super robust at the moment, but handles more than some of the other things mentioned, and it was more of what I was looking for.

    EDIT: In a single command, without installing any software:

    docker run --rm -v /var/run/docker.sock:/var/run/docker.sock nexdrew/rekcod redis_container
    

提交回复
热议问题