Last active
October 7, 2018 19:37
-
-
Save Pushplaybang/974ff65a17014b37aaafd5f5bcc9e0e2 to your computer and use it in GitHub Desktop.
Revisions
-
Pushplaybang revised this gist
Oct 7, 2018 . No changes.There are no files selected for viewing
-
Pushplaybang revised this gist
Oct 7, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # MY Docker Cheat Sheet a breif selection of essential commands, tips and notes about working with docker, as a personal reference. use at your own risk. ## Working with containers create and start a container -
Pushplaybang revised this gist
Oct 7, 2018 . 1 changed file with 23 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,10 +33,11 @@ Exiting an interactive session can usually be accomplished `cmd+c` will exit, if ## Dockerfile - `FROM` : specifty a base image to start from - `LABEL` : add arbitrary labels, such as `author` with `author=<you-name>` - `WORKDIR` : specify a working directory in the container (all commands after, use this as root) - `COPY` : copy somePath into the container working directory - `RUN` : run arbitrary commands - `CMD` : set an initial start command for when your container builds Here is an example Dockerfile ```sh @@ -50,9 +51,26 @@ RUN apk add --update redis CMD ["redis-server"] ``` this is a very basic container, here's another, thats slightly more complete: ```sh FROM node:alpine LABEL author="my-docker-id" WORKDIR /usr/app COPY ./package.json ./ RUN npm install COPY ./ ./ CMD ['npm', 'start'] ``` as each instruction is cached, the order is important, to avoid unneccessary rebuild steps and cache busting. ## Building containers after creating your `Dockerfile` run the following in your project dir: - `docker build -t <username/name> .` not that this will name your build with the `<username/name> .` . then run the following to start that container, notice we're parsing in the `-p` flag to specify the port, and are able to run the container by name, rather than id. - `docker run -p <external-port>:<container-port> <container-id or name>` -
Pushplaybang revised this gist
Oct 7, 2018 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,14 @@ run a command in a running contianer (optionally interactive) Exiting an interactive session can usually be accomplished `cmd+c` will exit, if not try `ctrl+d`, or simply type `exit` ## Dockerfile - `FROM` : specifty a base image to start from - `WORKDIR` : - `COPY` : - `RUN` : - `CMD` : Here is an example Dockerfile ```sh # use a base image @@ -43,6 +50,7 @@ RUN apk add --update redis CMD ["redis-server"] ``` ## Building containers after creating your `Dockerfile` run the following in your project dir: - `docker build -t <username/name> .` -
Pushplaybang revised this gist
Oct 7, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,3 +45,6 @@ CMD ["redis-server"] after creating your `Dockerfile` run the following in your project dir: - `docker build -t <username/name> .` not that this will name your build with the `<username/name> .` - `docker run -p <external-port>:<container-port> <container-id or name>` -
Pushplaybang revised this gist
Oct 7, 2018 . 1 changed file with 18 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## Working with containers create and start a container - `docker run [-a] <container-name> <override>` @@ -28,4 +28,20 @@ forcefully, and immediately, stop a container run a command in a running contianer (optionally interactive) - `docker exec [-it] <container-id> <command>` Exiting an interactive session can usually be accomplished `cmd+c` will exit, if not try `ctrl+d`, or simply type `exit` ## Building containers Here is an example Dockerfile ```sh # use a base image FROM alpine # dl and install deps RUN apk add --update redis # tell it what to do when it starts CMD ["redis-server"] ``` after creating your `Dockerfile` run the following in your project dir: - `docker build -t <username/name> .` -
Pushplaybang revised this gist
Oct 7, 2018 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,31 @@ create and start a container - `docker run [-a] <container-name> <override>` essentially runs the following two commands - `docker create <container-name> <override>` - `docker start [-a] <container-id>` list all running containers - `docker ps` list all containers - `docker ps --all` delete everything - `docker system prune` output logs for a running container - `docker logs <container-id>` gracefully stop a running container - `docker stop <container-id>` forcefully, and immediately, stop a container - `docker kill <container-id>` run a command in a running contianer (optionally interactive) - `docker exec [-it] <container-id> <command>` Exiting an interactive session can usually be accomplished `cmd+c` will exit, if not try `ctrl+d`, or simply type `exit` -
Pushplaybang created this gist
Oct 7, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ create and start a container `docker run [-a] <container-name> <override>` essentially runs the following two commands `docker create <container-name> <override>` `docker start [-a] <container-id>` list all running containers `docker ps` list all containers `docker ps --all` delete everything `docker system prune` output logs for a running container `docker logs <container-id>` gracefully stop a running container `docker stop <container-id>` forcefully, and immediately, stop a container `docker kill <container-id>` run a command in a running contianer (optionally interactive) `docker exec [-it] <container-id> <command>` Exiting an interactive session can usually be accomplished `cmd+c` will exit, if not try `ctrl+d`, or simply type `exit`