Skip to content

Instantly share code, notes, and snippets.

@tuffacton
Last active June 26, 2018 21:57
Show Gist options
  • Save tuffacton/5d1fc0c01d9d5fd2f6f7543dcaeff101 to your computer and use it in GitHub Desktop.
Save tuffacton/5d1fc0c01d9d5fd2f6f7543dcaeff101 to your computer and use it in GitHub Desktop.
Docker help scripts

Run a Docker container with a folder attached

$ docker run -it -v <path/to/folder>:</path/in/container> <container_name>

Commiting to new image

$ docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS              NAMES
c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours                            desperate_dubinsky
197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours                            focused_hamilton

$ docker commit c3f279d17e0a  svendowideit/testimage:version3

f5283438590d

$ docker images

REPOSITORY                        TAG                 ID                  CREATED             SIZE
svendowideit/testimage            version3            f5283438590d        16 seconds ago      335.7 MB

Add user (in this case ec2-user but you can find out your existing user using whoami) to docker group so you don't need sudo every time:

$ sudo usermod -a -G docker ec2-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment