{"id":18229706,"url":"https://github.com/mramshaw/docker","last_synced_at":"2026-04-08T18:31:25.101Z","repository":{"id":92905208,"uuid":"93462128","full_name":"mramshaw/Docker","owner":"mramshaw","description":"Experiments in Docker","archived":false,"fork":false,"pushed_at":"2019-10-28T16:36:23.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-08T09:22:46.773Z","etag":null,"topics":["docker","docker-image","dockerfile","dockerfiles","go","golang","mongodb","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mramshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-06-06T01:21:45.000Z","updated_at":"2019-10-28T16:36:25.000Z","dependencies_parsed_at":"2023-04-29T00:54:35.941Z","dependency_job_id":null,"html_url":"https://github.com/mramshaw/Docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mramshaw/Docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FDocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FDocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FDocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FDocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mramshaw","download_url":"https://codeload.github.com/mramshaw/Docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FDocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31568584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["docker","docker-image","dockerfile","dockerfiles","go","golang","mongodb","redis"],"created_at":"2024-11-04T10:03:06.361Z","updated_at":"2026-04-08T18:31:25.079Z","avatar_url":"https://github.com/mramshaw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker\n\n![Docker icon](images/Docker-R-Logo-08-2018-Monochomatic-RGB_Moby-x1.png)\n\nIn terms of the __Cloud__, learning [Docker](https://www.docker.com/) is a\ngreat first step.\n\nAll of the necessary concepts are present in Docker; cloud providers offer\nthe same functionality (albeit in somewhat different forms) but the basics\nare all present in Docker.\n\nIn addition, [DockerHub](http://hub.docker.com/u/mramshaw4docs) is a great\nway to share packaged software.\n\nEach cloud provider (AWS, Azure, GCP, Digital Ocean) has multiple services,\nincluding VMs (Virtual Machines). They also provide (generally as a premium\noffering) Container services.\n\nVarious __orchestration__ services are available, but all of the cloud providers\nlisted offer __Kubernetes__ (which is not to say that all of the offerings are\nidentical - some lag behind).\n\nAs a prelude to learning an orchestration service (such as Kubernetes), much\ncan be learned by starting with [docker-compose](https://docs.docker.com/compose/).\nHowever, the limitations of this approach quickly become apparent, but for\nprototyping purposes it is a great tool.\n\nEven so, Docker functions as an introduction to modern methodology such as\nthe [Twelve-factor App](http://12factor.net/processes).\n\n\u003e __Twelve-factor processes are stateless and share-nothing.__\n\n[This accords well with [Microservices](http://github.com/mramshaw/microservices) thinking.]\n\n__Nota bene__:\n\n\u003e Sticky sessions are a violation of twelve-factor and should never be used or relied upon.\n\n## Contents\n\nThe contents are as follows:\n\n* [Terminology](#terminology)\n* [Process](#process)\n* [Best Practices](#best-practices)\n    * [.dockerignore](#dockerignore)\n    * [FROM scratch](#from-scratch)\n    * [apt-get update / apk --update](#apt-get-update--apk---update)\n    * [sort dependencies](#sort-dependencies)\n    * [root access](#root-access)\n    * [Tag all images](#tag-all-images)\n* [ADD versus COPY](#add-versus-copy)\n* [Useful Shortcuts](#useful-shortcuts)\n    * [Detach from a container (but leave it running)](#detach-from-a-container-but-leave-it-running)\n    * [Exit a container](#exit-a-container)\n* [Useful Commands](#useful-commands)\n    * [General information about Docker and the Docker runtime](#general-information-about-docker-and-the-docker-runtime)\n    * [Current information about Docker runtime](#current-information-about-docker-runtime)\n    * [Processes](#processes)\n    * [Visibility into containers](#visibility-into-containers)\n    * [Images](#images)\n    * [Search Images](#search-images)\n    * [Tag Image](#tag-image)\n    * [Layer information about the Docker image](#layer-information-about-the-docker-image)\n    * [Docker logs](#docker-logs)\n    * [Docker volumes](#docker-volumes)\n\n## Terminology\n\nDocker itself is not too hard to learn and use, but in case you are ever asked\nthe difference between a __container__ and an __image__, here is my definition:\n\n\u003e A Docker __container__ wraps one or more Docker __images__ into a process\n\u003e with everything needed to run an application.\n\n[This is from an ___operating system___ point of view; from an ___application___\n point of view, it is of course your responsibility to add all of the software\n components needed to run your application.]\n\nIn general, the base image will correspond to a \\*nix operating system (such\nas CentOS) or a language (such as Node.js). In the case of a language image,\nall of the language components will be layered on top of a (probably) linux\nbase image (make a note of which one - it will be important).\n\n[Note that __DOCKER__ itself will handle the operating system issues, which\n means that \\*nix Docker images can be run on any hardware (such as a MacBook\n or Windows desktop) for which a version of Docker can be installed.]\n\n## Process\n\nMy personal Docker process is to start by selecting a ___Base image___ (all\nsubsequent software layers will then be layered on top of this image). This\nbase image might be __Alpine__, __CentOS__, __Debian__, __Ubuntu__ or even\na language image such as __Node.js__ or __Python__ or __Golang__ (these are\nsimply my usual choices and of course are not the only options - in fact the\navailable choices for a base Docker image are pretty much endless).\n\nGenerally, you should pick whichever linux distro you know best, unless you\ndecide to go with a language option - in which case the choice will probably\nbe obvious. If unsure which to pick, __CentOS__ is probably a safe choice.\n\n[Docker base images are generally linux-based, as the technology is based\n upon Linux Containers - which were themselves based upon\n [chroot jails](http://en.wikipedia.org/wiki/Chroot).]\n\nIn very rare situations I may decide to build [FROM scratch](#from-scratch),\nfor instance if I am simply distributing a pre-built binary.\n\nAnd I record the base image decision in a __Dockerfile__ (my preference is to\nalways use a __Dockerfile__ as they allow for simple and repeatable builds).\n\nThen I add my application's dependencies.\n\nAnd then I add my application.\n\nI will normally ___build___ my application in Docker (perhaps using a\n___buildbot___) and also ___test it___ in Docker. If these succeed, then\nI leave my application up and running.\n\nThere are variations on this theme, but that's generally my process.\n\n## Best Practices\n\nThe following are some suggested best practices:\n\n#### .dockerignore\n\nCreate a __.dockerignore__ file (essentially the same thing as a __.gitignore__ file)\nand list everything that Docker doesn't need to see in it (for instance __README.md__,\n__.git/__ and __.gitignore__ as well as any __passwords__ or __secrets__). This can also\nsave some transfer time in certain cases, such as when there is a lot of test data or\nsource files.\n\nInterestingly, Docker doesn't normally need to see the __.dockerignore__ file, so the\nfirst entry in this file should be:\n\n    .dockerignore\n\nCreate recursive wildcard patterns as follows:\n\n    **/*.obj\n    **/*.pyc\n\n[In this case, all .obj or .pyc files - in _any_ folder - will be ignored by Docker.]\n\n#### FROM scratch\n\nIn some circumstances you may wish to build your container starting from an empty image.\n\n[This is unusual but it is possible to think of many use cases where this would be desirable.]\n\nThe syntax for doing this is:\n\n```\nFROM scratch\n```\n\nYou can read the documentation for this option here:\n\n    http://docs.docker.com/samples/library/scratch/\n\n#### apt-get update / apk --update\n\nIn order to run an apples-to-apples comparison when testing/benchmarking, do __NOT__ do\neither an __apt-get update__ or an __apk --update__. The reason for this is that these\nwill make subtle changes to the operating systems that may well invalidate any test\ncomparisons.\n\nOf course, for production use, these are strongly recommended for security reasons.\n\n#### sort dependencies\n\nThis is so obvious that it almost goes without saying, but when installing dependencies\nwith __apt-get__ or __apk__ take the time to sort them alphabetically (or in some other\norder if that makes more sense).\n\nLarge numbers of dependencies can be hard to scan, so sorting them can make it easier\nto see what dependencies are being installed.\n\n#### root access\n\nConsider specifying __USER nobody__ unless __root__ access is absolutely required.\n[Hint: it is almost never actually required.]\n\n#### Tag all images\n\nThe default tag is __latest__ but it is a really terrible practice to use this. For one thing\nusing it means being vulnerable to new releases (not generally a good idea) - and can also\nhave a big impact in terms of having to actually download the latest release.\n\nFor consistency reasons, always tag Docker images - and only ever use tagged images. This will\nat least give you the option of actually __testing__ the latest release.\n\n## ADD versus COPY\n\nADD will uncompress certain files (.tar, .tar.gz, .tar.bz2) if only a destination directory\nis specified. It will __not__ uncompress certain other files (.zip). If the intent is to\ninclude a compressed file, make sure to specify a destination __name__ and directory.\n\nCOPY will simply copy the file, without uncompressing it (usually this is what's wanted).\n\nIf unsure, use COPY.\n\n## Useful Shortcuts\n\n[The usual practice on OS/X is to substitute the Option key for the Ctrl key;\n these are terminal commands, so don't.]\n\n#### Detach from a container (but leave it running)\n\nIt's not always convenient or possible to set up another terminal:\n\n\tCtrl-P followed by Ctrl-Q\n\nFor instance, when running in a Cloud Shell.\n\nTo reattach to the running container:\n\n\t$ docker attach xxxxxxxxxxxx\n\n#### Exit a container\n\nSlightly faster than typing `exit`:\n\n\tCtrl-D\n\n## Useful Commands\n\nOne or two useful Docker commands.\n\n#### General information about Docker and the Docker runtime:\n\n\t$ docker info\n\n#### Current information about the Docker runtime:\n\n\t$ docker stats\n\nAs usual, Ctrl-C to stop.\n\n#### Processes:\n\n\t$ docker ps\n\n\t$ docker ps -qa\n\n\t$ docker rm ...\n\n#### Visibility into containers\n\nSee into running containers with \u003ckbd\u003edocker top\u003c/kbd\u003e.\n\nStart a container:\n\n```bash\n$ docker run --name example -it busybox sh\n/ #\n```\n\nDetach from this container (but leave it running) with \u003ckbd\u003eCtrl-P\u003ckbd\u003e followed by \u003ckbd\u003eCtrl-Q\u003c/kbd\u003e.\n\nTo see what the container is running:\n\n```bash\n$ docker top example\nUID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD\nroot                9795                9777                0                   20:21               pts/0               00:00:00            sh\n$\n```\n\nAnd clean up:\n\n```bash\n$ docker kill example\nexample\n$ docker rm example\nexample\n$\n```\n\n#### Images:\n\n\t$ docker images\n\n\t$ docker rmi ...\n\n#### Search Images:\n\nThis can be significantly faster than searching [DockerHub](https://hub.docker.com/)\n(or any other repository) manually:\n\n\t$ docker search rediswebserver\n\n[Replace `rediswebserver` with whatever software is of interest.]\n\nOfficial builds will show first. By default only __25__ images will be shown, but\nthis is usually more than enough. The __STARS__ column is particularly helpful:\n\n```bash\n$ docker search redis --no-trunc\nNAME                             DESCRIPTION                                                                            STARS               OFFICIAL            AUTOMATED\nredis                            Redis is an open source key-value store that functions as a data structure server.     6978                [OK]\nbitnami/redis                    Bitnami Redis Docker Image                                                             113                                     [OK]\nsameersbn/redis                                                                                                         75                                      [OK]\ngrokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0 \u0026 5.0                                                      48\nkubeguide/redis-master           redis-master with \"Hello World!\"                                                       29\nrediscommander/redis-commander   Alpine image for redis-commander - Redis management tool.                              24                                      [OK]\nredislabs/redis                  Clustered in-memory database engine compatible with open source Redis by Redis Labs    20\narm32v7/redis                    Redis is an open source key-value store that functions as a data structure server.     15\nredislabs/redisearch             Redis With the RedisSearch module pre-loaded. See http://redisearch.io                 15\noliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supports Redis 2.x, 3.x, 4.x and 5.x           10\nwebhippie/redis                  Docker images for Redis                                                                10                                      [OK]\ns7anley/redis-sentinel-docker    Redis Sentinel                                                                         8                                       [OK]\ninsready/redis-stat              Docker image for the real-time Redis monitoring tool redis-stat                        7                                       [OK]\narm64v8/redis                    Redis is an open source key-value store that functions as a data structure server.     6\nredislabs/redisgraph             A graph database module for Redis                                                      5                                       [OK]\ncentos/redis-32-centos7          Redis in-memory data structure store, used as database, cache and message broker       4\nbitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel                                                4                                       [OK]\nfrodenas/redis                   A Docker Image for Redis                                                               2                                       [OK]\ncircleci/redis                   CircleCI images for Redis                                                              2                                       [OK]\nwodby/redis                      Redis container image with orchestration                                               2                                       [OK]\nkilsoo75/redis-master            This image is for the redis master of SK CloudZ                                        1\ntiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Overlay based on Alpine                       1                                       [OK]\ncflondonservices/redis           Docker image for running redis                                                         0\nxetamus/redis-resource           forked redis-resource                                                                  0                                       [OK]\n$\n```\n\n#### Tag Image:\n\nDocker images are generally tagged __latest__ by default.\n\nAs each successive __latest__ image is built, it usually leaves behind an unnamed orphan image.\nUse __rmi__ (see above) to delete these.\n\nTo tag an image with a version number (in this case 1.1):\n\n\t$ docker tag xxx/yyy xxx/yyy:1.1\n\n#### Layer information about the Docker image:\n\n\t$ docker history ...\n\n\t$ docker history --no-trunc ...\n\n#### Docker logs:\n\n\t$ docker logs xxxxxxxxxxxx\n\n#### Docker volumes:\n\n\t$ docker volume ls\n\n\t$ docker volume prune\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmramshaw%2Fdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmramshaw%2Fdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmramshaw%2Fdocker/lists"}