nexdrew / rekcod

docker inspect :mag: → docker run :runner:
ISC License
371 stars 32 forks source link

Added Dockerfile (to run rekcod using Docker) #27

Closed MPV closed 6 years ago

MPV commented 6 years ago

Hi @nexdrew, Thanks for creating this awesome project!

I've added a Dockerfile that makes it possible to run this as a Docker container.

How to use it:

Build docker image:

docker build -t rekcod .

Example:

$ docker build -t rekcod .

Sending build context to Docker daemon  265.7kB
Step 1/4 : FROM docker
 ---> cc2d9a7e463b
Step 2/4 : RUN apk add --no-cache nodejs nodejs-npm
 ---> Using cache
 ---> c58d21a5137d
Step 3/4 : RUN npm install -g rekcod
 ---> Using cache
 ---> c9804d8429bb
Step 4/4 : ENTRYPOINT ["rekcod"]
 ---> Running in 11fee8c4608c
Removing intermediate container 11fee8c4608c
 ---> e42250622910
Successfully built e42250622910
Successfully tagged rekcod:latest

Run docker container:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock rekcod name-of-container-to-inspect-here

Example:

$ docker run --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    --name rekcod rekcod tutum-hello-world

docker run --name tutum-hello-world -p 80:80/tcp --restart no -h 60dc8f702c18 --expose 80/tcp -e 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' -a stdout -a stderr tutum/hello-world /bin/sh -c php-fpm -d variables_order="EGPCS" && (tail -F /var/log/nginx/access.log &) && exec nginx -g "daemon off;"

Next steps:

@nexdrew: Would you be open to adding the image from this repo to Docker Hub (after merging the PR?)?

  1. Here's how to manually publish to Docker Hub: https://docs.docker.com/docker-cloud/builds/push-images/

  2. Here is a guide how to auto-publish from GitHub to Docker Hub: https://docs.docker.com/docker-hub/github/

MPV commented 6 years ago

Leaving this here for reference:

runlike seems to be able to do the same thing: https://github.com/lavie/runlike#run-without-installing

nexdrew commented 6 years ago

@MPV Wow, thanks for the detailed suggestion/contribution! I think this is a great idea. I should have some time later today to dive into this and provide feedback. Thanks again!

nexdrew commented 6 years ago

@MPV Hi, sorry it has taken me a few days to look into this.

Instead of building from the docker image and installing node/npm, what do you think about building from mhart/alpine-node instead and then running/using it this way?

$ docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker nexdrew/rekcod:2.1.0 <name_of_container>

This would use the docker bin from the host OS (instead of requiring the docker bin to be baked into the image) and would allow the image to be smaller (67.5MB instead of 177MB).

If you don't like that idea, we could also publish both versions under different tags or versions, so folks could choose which one they want.

Once we decide, we should add something to the README that describes the zero-install usage of rekcod. 😃

nexdrew commented 6 years ago

Sorry to let this stall, I'm happy with this contribution. What I plan to do is merge this, follow it up with a readme update, and then I'll publish to Docker Hub.

Thanks for contributing!

nexdrew commented 6 years ago

@MPV Thanks to your contribution, rekcod has been published to Docker Hub and can now be run without Node installed: https://hub.docker.com/r/nexdrew/rekcod/

Thanks again for your valuable contribution!