{"id":18876290,"url":"https://github.com/mbarany/docker-example","last_synced_at":"2025-08-12T15:14:15.540Z","repository":{"id":150042637,"uuid":"162210500","full_name":"mbarany/docker-example","owner":"mbarany","description":"Docker example with notes","archived":false,"fork":false,"pushed_at":"2019-01-08T01:56:14.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-27T23:42:47.557Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbarany.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-18T01:06:31.000Z","updated_at":"2022-03-24T17:26:13.000Z","dependencies_parsed_at":"2023-04-04T20:34:25.294Z","dependency_job_id":null,"html_url":"https://github.com/mbarany/docker-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mbarany/docker-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarany%2Fdocker-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarany%2Fdocker-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarany%2Fdocker-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarany%2Fdocker-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbarany","download_url":"https://codeload.github.com/mbarany/docker-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbarany%2Fdocker-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270083009,"owners_count":24523847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-08T06:12:12.195Z","updated_at":"2025-08-12T15:14:15.520Z","avatar_url":"https://github.com/mbarany.png","language":"Shell","readme":"# Docker\nIntroduction to Docker example and notes\n\n## What is docker?\n- https://www.itzgeek.com/wp-content/uploads/2017/05/Build-Docker-Images-with-DockerFile.png\n- https://images.idgesg.net/images/article/2017/06/virtualmachines-vs-containers-100727624-large.jpg\n\n\n## Installation (Mac)\n```bash\nbrew cask install docker\n```\n\n\n## Terminology\n- docker file (Dockerfile)\n- docker image (eg. `nginx:latest`)\n- docker container\n- docker volume\n- docker network\n- docker registry (dockerhub, ECR)\n- docker-compose\n\n\n## Image naming \u0026 tags\n- mbarany/docker-example\n- mbarany/docker-example:latest\n- mbarany/docker-example:1.0\n- ubuntu:18.04\n- nginx:latest\n\n\n## Dockerfile\nDocumentation: https://docs.docker.com/engine/reference/builder/#from\n\nDockerfile Example:\n```Dockerfile\nFROM ubuntu:18.04\nCOPY . /app\nRUN make /app\nCMD python /app/app.py\n```\n\n\n## Docker Registry\nhttps://hub.docker.com/\n- pull images\n  ```bash\n  docker pull nginx:latest\n  ```\n- push images\n  ```bash\n  docker push mbarany/docker-example:latest\n  ```\n\n\n## Library\nhttps://hub.docker.com/u/library\n- Ubuntu\n- Postgres\n- MySQL\n- Redis\n- Python\n- Nginx\n\n\n## run\n```bash\ndocker run alpine /bin/sh\n# The following subshell will run on the host (as expected)\ndocker run alpine echo \"hi from alpine: $(uname -rs)\"\ndocker run alpine sh -c 'echo \"hi from alpine: $(uname -rs)\" \u0026\u0026 echo \"more stuff\"'\ndocker run -it alpine /bin/sh\ndocker run -it --rm alpine\ndocker run -it --rm --name my-alpine alpine\n```\n- Use `--rm`\n- Use `--name \u003ccontainer name\u003e`\n\n\n## Path to a Container\n1. Create Dockerfile\n1. Build Dockerfile and create Image\n1. Start container with a given Image\n\n\n## build\n```bash\ndocker build -t mbarany/docker-example .\ndocker build -t mbarany/docker-example:latest .\ndocker build -f Dockerfile -t mbarany/docker-example:latest .\n```\n\n\n## exec\n```bash\ndocker exec -it \u003ccontainer\u003e /bin/sh\n```\n\n\n## logs\n```bash\ndocker logs -f nginx\ndocker logs -f --tail 50 nginx\n```\n\n\n# Part 2\n\n\n## port bindings\n```bash\n# Publish all\ndocker run --rm -d --name nginx -P nginx\n# Publish list\ndocker run --rm -d --name nginx -p 80 nginx\ndocker run --rm -d --name nginx -p 9999:80 nginx\n```\n\n\n## volumes\n```bash\n# List volumes\ndocker volume ls\n# Map volume\ndocker run --rm -it --name myapp -v \"$(pwd)\":/app alpine\n# Make it read only\ndocker run --rm -it --name myapp -v \"$(pwd)\":/app:ro alpine\n# Create a volume\ndocker volume create foobar\ndocker run --rm -it --name myapp -v foobar:/app/foobar alpine\n```\n\n\n## docker-compose\n```yaml\nversion: '3.4'\n\nservices:\n  app:\n    build: .\n    depends_on:\n     - db\n     - redis\n    volumes:\n      - ./:/app\n    environment:\n      FOOBAR: bar\n    env_file:\n      - .env\n\n  db:\n    image: postgres:10-alpine\n\n  redis:\n    image: redis:alpine\n```\nhttps://docs.docker.com/compose/compose-file/\n\n`docker-compose up -d`\n\n\n# Part 3\n\n\n## docker-compose examples\nView advanced examples of docker-compose.yml files\n\n\n## networking\nhttps://docs.docker.com/network/\n- host\n- bridge\n- none\n```bash\n# List networks\ndocker network ls\n# Create network\ndocker network create foo\n# Delete network\ndocker network rm foo\n```\n\n\n## restart policy\nhttps://docs.docker.com/compose/compose-file/compose-file-v2/#restart\nhttps://docs.docker.com/compose/compose-file/#restart_policy\n\n\n## Alpine\nTiny linux distro. Perfect for a docker container base\n- `apk` Package manager\n\n\n## Entrypoint VS CMD\nhttps://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile/21564990#21564990\n\n\n## docker inspect\n```bash\ndocker inspect mbarany/docker-example\n# brew install dive\ndive mbarany/docker-example\n```\n\n## Scratch\nThis is where all docker images begin\nhttps://hub.docker.com/_/scratch\n\n\n## Other docker things\n- https://github.com/veggiemonk/awesome-docker\n\n\n# License\nCopyright 2018 Michael Barany\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbarany%2Fdocker-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbarany%2Fdocker-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbarany%2Fdocker-example/lists"}