Skip to content

Instantly share code, notes, and snippets.

@SGTGunner
Forked from chaojian-zhang/DockerUsageNotes.md
Created February 5, 2022 19:36
Show Gist options
  • Save SGTGunner/480b919fd1baeb53967da899382d80a2 to your computer and use it in GitHub Desktop.
Save SGTGunner/480b919fd1baeb53967da899382d80a2 to your computer and use it in GitHub Desktop.
Docker Usages Notes

Basics

  • docker run --name <your_container_name> alpine/git <git_command>
  • docker run -it --name <your_container_name> alpine/git <git_command>: Run with tty interactive
  • docker run -d --name couch -p 8091-8094:8091-8094 -p 11210:11210 couchbase: Run (e.g. a server) unattached
  • docker cp container_name:/git/getting-started .: Copy files/folders between a container and the local filesystem
  • docker start <your_container_name>: Start a stopped container
  • docker attach <your_container_name>: Attach to running container
  • docker exec -it couch cbq --user Administrator (docker exec -it <container name> <command>): Execute commands
  • docker exec -it <container name> /bin/bash: Attach to running container, run a bash shell; With VS Code, you can also directly attach to running container.
  • docker stop <container_name_old> then docker commit <container_name_old> <container_name_new> then docker run --name <container_name_new> -p 7777:7777/udp -td <new_image_name> to "restart a container with port mapping" - you can only specify port mapping with docker run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment