{"id":17160384,"url":"https://github.com/codenameyau/docker-cheatsheet","last_synced_at":"2026-01-25T18:32:08.930Z","repository":{"id":38800117,"uuid":"53809184","full_name":"codenameyau/docker-cheatsheet","owner":"codenameyau","description":":whale: Docker cheatsheet and images","archived":false,"fork":false,"pushed_at":"2022-12-26T20:16:10.000Z","size":54,"stargazers_count":3,"open_issues_count":11,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-21T13:53:11.454Z","etag":null,"topics":["containers","devops","docker","flask","nginx"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codenameyau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-13T21:40:00.000Z","updated_at":"2022-07-03T17:11:29.000Z","dependencies_parsed_at":"2022-08-26T19:53:11.435Z","dependency_job_id":null,"html_url":"https://github.com/codenameyau/docker-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codenameyau/docker-cheatsheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdocker-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdocker-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdocker-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdocker-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codenameyau","download_url":"https://codeload.github.com/codenameyau/docker-cheatsheet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenameyau%2Fdocker-cheatsheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28756442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","devops","docker","flask","nginx"],"created_at":"2024-10-14T22:24:41.302Z","updated_at":"2026-01-25T18:32:08.914Z","avatar_url":"https://github.com/codenameyau.png","language":"Python","readme":"# docker-examples\n- https://github.com/wsargent/docker-cheat-sheet\n- https://docs.docker.com/get-started/part2/\n- http://containertutorials.com/docker-compose/flask-simple-app.html\n- https://jpetazzo.github.io/2013/12/01/docker-python-pip-requirements/\n\n## Cheatsheet\n\n```bash\n# Starts a container.\ndocker start\n\n# Stop all containers.\ndocker stop $(docker ps -aq)\n\n# Remove all containers.\ndocker rm $(docker ps -aq)\n\n# Pruning unused images.\ndocker system prune -a\n\n# Remove image.\ndocker rmi \u003cimage-id\u003e\n\n# Remove all images.\ndocker rmi $(docker images -q)\n\n# List running containers.\ndocker ps\n\n# Lists all containers and list just the container ids.\ndocker ps -a\n\n# List just the container ids.\ndocker ps -q\n```\n\n### Building and running a local container\n\n```bash\n# Find your new docker image.\ndocker images\n\n# Build the image\ndocker build -t \u003cimage-name\u003e .\n\n# Run container in detached mode.\ndocker run -d \u003cname\u003e\n\n# Run container (forward ports -\u003e host:guest)\ndocker run -dit -p 8080:80 \u003cimage-id-or-name\u003e\n\n# (Optional) You can also specify the container name.\ndocker run -dit -p 8080:80 \u003cimage-id-or-name\u003e -name \u003ccontainer-name\u003e\n\n# Debug exited containers by removing the '-d' flag.\ndocker run -it \u003cimage-id-or-name\u003e\n\n# Run container with synced volume from host to guest.\ndocker run -it -p 8080:80 -v $(pwd):\u003cguest-dir\u003e \u003cimage-name\u003e\n\n# Example: /darth_varder/ will be available in guest.\ndocker run -it -v $HOME/Workspace/tf_files:/darth_vader c3efccc5f94f\n\n# SSH into container via attachment (halts process if you exit).\ndocker attach \u003ccontainer-id\u003e\n\n# SSH into container via new process (won't halt if you exit).\ndocker exec -it \u003ccontainer-id\u003e bash\n```\n\n### Basic Setup\n```bash\ndocker build -t nltk-flask .\ndocker run -dit -p 5000:5000 nltk-flask\n```\n\nThen visit: http://localhost:5000\n\n```bash\n# To enter container, run:\ndocker ps\ndocker exec -it \u003ccontainer-id-or-name\u003e bash\n\n# While inside container use exit to prevent shutting down container.\n$ exit\n```\n\n## Publishing container to Dockerhub\n\n```bash\n# Build image locally.\ndocker build -t \u003cusername\u003e/\u003crepo\u003e .\n\n# Create a Dockerhub account.\nhttps://hub.docker.com/\n\n# Log into your Dockerhub account in your terminal.\ndocker login\n\n# Publish container\ndocker push \u003cusername\u003e/\u003crepo\u003e\n```\n\n## Docker on MacOS\n\nhttps://docs.docker.com/docker-for-mac/\n\nThis link will tell you everything about setting up docker for Mac, what the GUI does,\nhow to setup preferences, how to start file sharing, and how to perform more advanced\ntasks such as setting up certificates.\n\n### Setup\nTry to run this simple command to spin up a new nginx docker webserver.\n```bash\ndocker run -d -p 80:80 --name webserver nginx\n```\n\nIf you see this error, then open up Docker application via GUI with CMD+space, then\ntype docker. It will tell you to install and relaunch docker.\n```bash\ndocker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.\n```\n\nOnce that's complete you can stop or remove the web server container.\n```bash\ndocker stop webserver\ndocker rm -f webserver\ndocker rmi nginx\n```\n\n## Docker scan\nDocker scan is a tool that can be used to scan for container security vulnerabilities. It returns an exit code 1\nwhenever there is a high severity vulnerabiity and can be added into a CI/CD pipeline.\n\n```sh\n# Log into docker hub account.\ndocker login\n\n# Scan image for vulnerabilities.\ndocker scan \u003cimage\u003e\n```\n\n\n## Anchore\nAnchore is a tool that can be integrated with the CI/CD pipeline to automate the process of checking for security\nvulnerabilities in a Docker image. As a safe precaution it is better to bump the amount of memory in your\ndocker settings to around 4GB. \n\nYou can run the script as a quick scan:\n\n```\ncurl -s https://ci-tools.anchore.io/inline_scan-latest | bash -s -- -d ./Dockerfile image:latest\ncurl -s https://ci-tools.anchore.io/inline_scan-latest | bash -s -- -d ./Dockerfile ocr-1:latest\n```\n\n\nTo get started with the anchore-cli, follow the instructions on this README:\n\nhttps://github.com/anchore/anchore-engine\n\n\n```sh\n# Add an image from docker.io\nanchore-cli --u admin --p foobar image add node:14\n\n# Add an image from host machine. (TODO)\nanchore-cli --u admin --p foobar image add node:14\n\n# List images.\nanchore-cli --u admin --p foobar image list\n\n# Get image details.\nanchore-cli --u admin --p foobar image get node:12\n\n# See files.\nanchore-cli --u admin --p foobar image content node:12 files\n\n# See OS libraries.\nanchore-cli --u admin --p foobar image content node:12 os\n\n# See image vulnerabilities\nanchore-cli --u admin --p foobar image vuln node:12 os\n\n# See system status.\nanchore-cli --u admin --p foobar system status\n\n# See system feed.\nanchore-cli --u admin --p foobar system feeds list\n```\n\nYou can also set the following environment variables for authorization so you can omit the `--u admin` and `--p foobar` options.\n\n```sh\n# First set these environment variables.\nANCHORE_CLI_URL=http://localhost:8228/v1\nANCHORE_CLI_USER=admin\nANCHORE_CLI_PASS=foobar\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenameyau%2Fdocker-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodenameyau%2Fdocker-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenameyau%2Fdocker-cheatsheet/lists"}