{"id":16370871,"url":"https://github.com/integralist/docker-examples","last_synced_at":"2025-07-20T10:33:03.372Z","repository":{"id":140160592,"uuid":"21289222","full_name":"Integralist/Docker-Examples","owner":"Integralist","description":"Testing Docker","archived":false,"fork":false,"pushed_at":"2016-07-18T20:17:42.000Z","size":337,"stargazers_count":29,"open_issues_count":1,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T12:04:16.664Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Integralist.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":"2014-06-27T21:02:44.000Z","updated_at":"2022-02-09T14:20:16.000Z","dependencies_parsed_at":"2023-04-07T13:03:01.114Z","dependency_job_id":null,"html_url":"https://github.com/Integralist/Docker-Examples","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"16784673ba9921fd0e213925ca10daab29286fee"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Integralist/Docker-Examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDocker-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDocker-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDocker-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDocker-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Integralist","download_url":"https://codeload.github.com/Integralist/Docker-Examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDocker-Examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266111435,"owners_count":23877980,"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","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-10-11T03:06:20.149Z","updated_at":"2025-07-20T10:33:03.355Z","avatar_url":"https://github.com/Integralist.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker\n\n- [Introduction](#introduction)\n- [Exposing the Docker daemon](#exposing-the-docker-daemon)\n- [Help with Docker commands](#help-with-docker-commands)\n- [CMD vs ENTRYPOINT](#cmd-vs-entrypoint)\n- [Alternative CoreOS/Vagrantfile](#alternative-coreosvagrantfile)\n- [Example Docker Containers](#example-docker-containers)\n- [VMWare Provider](#vmware-provider)\n\n## Introduction\n\nGetting Docker set-up on a non-Linux environment (such as a Mac) can be done in a few ways; below are a few popular options:\n\n1. Use Docker's \"Boot2Docker\" VM (uses VirtualBox to set-up the VM)\n2. Use a CoreOS VM via Vagrant (with some modifications, such as exposing a private ip)\n\nWe're going to use the latter option. The host will attempt to connect directly to the VM's private ip (although, as we'll see in the next section, the Docker daemon needs to be exposed too for that to happen).\n\n## Exposing the Docker daemon\n\n\u003e UPDATE: the Vagrantfile executes a `provision.sh` which automates all of the below steps for you\n\nIf you just do a `vagrant up` and try to run a Docker command (such as `docker ps`) then you'll get an error, like: `Cannot connect to the Docker daemon. Is 'docker -d' running on this host?`.\n\nFor the host to be able to use the Docker CLI, the Docker daemon on CoreOS needs to be exposed via a TCP port (as we're setting an ip address to access the CLI like so: `export DOCKER_HOST=tcp://172.17.8.100:2375`).\n\nThe following are the steps required to do this:\n\nAdd `export DOCKER_HOST=tcp://172.17.8.100:2375` to your `.zshrc` (or `.bashrc`) configuration file (as per the private ip defined inside the CoreOS Vagrantfile).\n\nRead: http://coreos.com/docs/launching-containers/building/customizing-docker/ but effectively the steps are:\n\n- `vagrant up`\n- `vagrant ssh`\n- `sudo touch /etc/systemd/system/docker-tcp.socket`\n- Add following content into above socket file:\n\n```\n[Unit]\nDescription=Docker Socket for the API\n\n[Socket]\nListenStream=2375\nService=docker.service\nBindIPv6Only=both\n\n[Install]\nWantedBy=sockets.target\n```\n\n- `sudo systemctl enable docker-tcp.socket`\n- `sudo systemctl stop docker`\n- `sudo systemctl start docker-tcp.socket`\n- `sudo systemctl start docker`\n- `exit`\n- `docker ps`\n\n\u003e Note: if you're using Ubuntu and not CoreOS then see https://github.com/Integralist/Linux-and-Docker-Development-Environment/blob/master/provision.sh#L49-L55 for example of exposing the Docker daemon ip\n\n## Help with Docker commands\n\n- `docker help` lists all commands\n- `docker help [command]` lists all options for specified command\n\n## CMD vs ENTRYPOINT\n\nhttp://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile\n\nEffectively, Docker has a default `ENTRYPOINT` which is `/bin/sh -c`. \n\nA typical Docker command will look like (where, for example `{COMMAND}` is `bash`):\n\n`docker run -i -t {IMAGE_NAME} {COMMAND}` \n\ne.g. `docker run -i -t MY_IMAGE bash`\n\nIn the above example you're passing the command `bash` to the default `ENTRYPOINT` (`/bin/sh -c`) which would drop us into a Bash shell ready to execute some more commands within the Docker container.\n\nIn the `Dockerfile` you can change the `ENTRYPOINT` to be something else, so you could change it to be the `cat` command instead of `sh` (e.g. `ENTRYPOINT [\"/bin/cat\"]`). \n\nIf you did that for your Docker container then you could pass in a \"command\" to the container like so:\n\n`docker run -i -t MY_IMAGE /etc/passwd` which would pass the command `/etc/passwd` to the `cat` command\n\n\u003e You can also override the ENTRYPOINT via the command-line using the `--entrypoint` flag:  \n`docker run --rm -it --entrypoint=/bin/bash my_image`\n\n## Alternative CoreOS/Vagrantfile\n\nThe following is a simplified `Vagrantfile`. It's similiar but minus the comments and also doesn't work-around everything that the `Vagrantfile` within this repo caters for:\n\n```rb\nVagrant.configure('2') do |config|\n  config.vm.box = \"coreos\"\n  config.vm.box_url = \"http://storage.core-os.net/coreos/amd64-generic/dev-channel/coreos_production_vagrant.box\"\n  config.vm.network \"private_network\",  ip: \"172.17.8.100\"\n  config.vm.synced_folder \".\", \"/home/core/share\",\n    id: \"core\",\n    :nfs =\u003e true,\n    :mount_options =\u003e ['nolock,vers=3,udp']\nend\n```\n\n## Example Docker Containers\n\nThis repository has basic Dockerfiles for both NodeJS and Ruby Sinatra applications. To build the containers please read the instructions for each container.\n\n## VMWare Provider\n\nIf you're using VMWare as your provider (e.g. `vagrant up --provider=vmware_fusion`) then you might run into an issue mounting your folders into the CoreOS VM.\n\nThe error might look something like the following...\n\n```\nBringing machine 'default' up with 'vmware_fusion' provider...\n==\u003e default: Cloning VMware VM: 'coreos-alpha'. This can take some time...\n==\u003e default: Checking if box 'coreos-alpha' is up to date...\n==\u003e default: Verifying vmnet devices are healthy...\n==\u003e default: Preparing network adapters...\n==\u003e default: Fixed port collision for 22 =\u003e 2222. Now on port 2200.\n==\u003e default: Starting the VMware VM...\n==\u003e default: Waiting for machine to boot. This may take a few minutes...\n    default: SSH address: 172.16.82.134:22\n    default: SSH username: core\n    default: SSH auth method: private key\n==\u003e default: Machine booted and ready!\n==\u003e default: Forwarding ports...\n    default: -- 22 =\u003e 2200\n==\u003e default: Setting hostname...\n==\u003e default: Configuring network adapters within the VM...\n==\u003e default: Exporting NFS shared folders...\n==\u003e default: Preparing to edit /etc/exports. Administrator privileges will be required...\n==\u003e default: Mounting NFS shared folders...\nThe following SSH command responded with a non-zero exit status.\nVagrant assumes that this means the command failed!\n\nmount -o 'nolock,vers=3,udp' 172.17.8.1:'/Users/foobar/path/to/current/directory' /home/core/share\n\nStdout from the command:\n\n\n\nStderr from the command:\n\nmount.nfs: access denied by server while mounting 172.17.8.1:/Users/foobar/path/to/current/directory\n```\n\nIt turns out this might be an issue with CoreOS not assigning the private \"host-only\" network ip address properly: https://github.com/coreos/coreos-vagrant/issues/159#issuecomment-54267821\n\nIf you were to `vagrant ssh` onto the box and run `ifconfig` you would notice the ip address assigned is not the one requested in the `Vagrantfile`. But if you then checked the CoreOS network settings (run `cat /etc/systemd/network/50-vagrant1.network`) then you'll see that the ip address listed matches what is defined inside our `Vagrantfile`.\n\n### Work around\n\nTo work around this issue (temporarily, until an official fix is found) I would suggest running through the following steps:\n\n#### Host machine (i.e. your Mac)\n\n- Run `sudo vim /etc/exports/` and edit the relevant command so that the ip address (the one that matches what's defined in the `Vagrantfile`) is removed -\u003e this means the VM makes the mount available to all users\n- Run `sudo nfsd restart`\n\n#### CoreOS VM\n\n- `sudo mount -o 'nolock,vers=3,udp' 172.17.8.1:'/Users/foo/path/to/directory' /home/core/share` (make sure to change `/Users/foo/path/to/directory` to your directory -\u003e you can get this command out of the failed `vagrant up` output)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fdocker-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegralist%2Fdocker-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fdocker-examples/lists"}