{"id":15173929,"url":"https://github.com/binarweb/docker-tutorial","last_synced_at":"2026-02-11T18:30:18.748Z","repository":{"id":176643243,"uuid":"191981993","full_name":"binarweb/docker-tutorial","owner":"binarweb","description":"Installing Docker on a Digital Ocean droplet with Ubuntu 18.04 with an example","archived":false,"fork":false,"pushed_at":"2019-06-28T10:57:53.000Z","size":41,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-30T21:45:47.525Z","etag":null,"topics":["digitalocean","docker","mariadb","mariadb-server","ubuntu1804","ubunutu"],"latest_commit_sha":null,"homepage":"","language":null,"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/binarweb.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":"2019-06-14T17:27:52.000Z","updated_at":"2020-02-16T16:01:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"f35ac9e1-cca2-41b3-8b6b-0fb47dbc9051","html_url":"https://github.com/binarweb/docker-tutorial","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"d320cf965ecefee403e12c2e131b174190ff92af"},"previous_names":["binarweb/docker-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarweb%2Fdocker-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarweb%2Fdocker-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarweb%2Fdocker-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarweb%2Fdocker-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binarweb","download_url":"https://codeload.github.com/binarweb/docker-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239808533,"owners_count":19700454,"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":["digitalocean","docker","mariadb","mariadb-server","ubuntu1804","ubunutu"],"created_at":"2024-09-27T11:05:01.938Z","updated_at":"2026-02-11T18:30:18.708Z","avatar_url":"https://github.com/binarweb.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker tutorial\n\nInstallation will take place on a Digital Ocean droplet with Ubuntu 18.04  \n\n## 1. Installing some tools (optional)\n\n```bash\napt update\napt install git mc htop screen -y\n```\n\n## 2. Install docker\n\n```bash\napt update\napt install apt-transport-https ca-certificates curl software-properties-common -y\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -\nadd-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable\"\napt update\napt-cache policy docker-ce\napt install docker-ce -y\n```\n\nTo test the status of docker service:  \n```\nsystemctl status docker\n```\n\n## 3. Run a docker image in a container\n\n```\ndocker run hello-world\n```\n\nThe output will be something like this\n\n\u003cpre\u003e\nUnable to find image 'hello-world:latest' locally\nlatest: Pulling from library/hello-world\n1b930d010525: Pull complete\nDigest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8\nStatus: Downloaded newer image for hello-world:latest\n\nHello from Docker!\nThis message shows that your installation appears to be working correctly.\n\nTo generate this message, Docker took the following steps:\n 1. The Docker client contacted the Docker daemon.\n 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\n    (amd64)\n 3. The Docker daemon created a new container from that image which runs the\n    executable that produces the output you are currently reading.\n 4. The Docker daemon streamed that output to the Docker client, which sent it\n    to your terminal.\n\nTo try something more ambitious, you can run an Ubuntu container with:\n $ docker run -it ubuntu bash\n\nShare images, automate workflows, and more with a free Docker ID:\n https://hub.docker.com/\n\nFor more examples and ideas, visit:\n https://docs.docker.com/get-started/\n\u003c/pre\u003e\n\nNote that the container prints the message and exists immediately.\n\n## 4. Runing a docker image with interactive shell\n\n```\ndocker run -it ubuntu\n```\n\nNote that any change you make in the container is persistent between the container restarts.\n\n## 5. List running containers\n\n```\ndocker ps\n```\n\n## 6. List all containers (active and inactive)\n\n```\ndocker ps -a\n```\n\n## 7. Start a stopped container\n\n```\ndocker start d9b100f2f636\n```\n\nwhere `d9b100f2f636` is the `CONTAINER ID` that is listed in the `docker ps -a` command\n\n## 8. Keep the container running\n\n```\ndocker run -d ubuntu tail -f /dev/null\n```\n\nwhere `ubuntu` is the image name\n\n## 9. Stop a running container\n\n```\ndocker stop d9b100f2f636\n```\n\nwhere `d9b100f2f636` is the `CONTAINER ID` that is listed in the `docker ps -a` command\n\n```\ndocker stop -t=30 d9b100f2f636\n```\n\n`-t=30` will allow the container to gracefully stop\n\n## 10. Remove (delete) a container\n\n```\ndocker rm d9b100f2f636\n```\n\nwhere `d9b100f2f636` is the `CONTAINER ID` that is listed in the `docker ps -a` command\n\n## 11. SSH into a running container\n\n```\ndocker exec -it d9b100f2f636 /bin/bash\n```\n\nwhere `d9b100f2f636` is the `CONTAINER ID` that is listed in the `docker ps -a` command\n\n## 12. List available images\n\n```\ndocker images\n```\n\n## 13. Search for images\n\n```\ndocker search ubuntu\n```\n\nDefault limit is 25. To list more results use `--limit 100` option.  \nThe images are listed from https://hub.docker.com/  \n\n## 14. Create a custom image\n\n```\nmkdir DOCKER-IMAGE-TEST\ncd DOCKER-IMAGE-TEST\nnano Dockerfile\n```\n\nand paste  \n\n```\nFROM ubuntu\nMAINTAINER Gigel \u003cuser@email.tld\u003e\n\nRUN apt-get update --fix-missing \u0026\u0026 apt-get install -y apache2\n\nEXPOSE 80\n\nCMD [\"service\", \"apache2\", \"start\"]\n```\n\ncreate the image by running\n\n```\ndocker build -t ubuntu:apache2 .\n```\n\nafter it completes, the images will be in the list of images\n\n## 15. Delete an image\n\n```\ndocker rmi Image\n```\n\nwhere `Image` is the image name\n\n## 16. Clean up docker\n\n```\ndocker system prune\n```\n\nIt will delete images, containers, volumes, and networks — that are dangling (not associated with a container).\n\n## 17. Exposing ports to the ouside of containers (local machine)\n\n```\ndocker run -p 127.0.0.1:80:80 -d ubuntu:apache2 tail -f /dev/null\n```\n\nto make sure the port is exposed, run\n\n```\nnetstat -tulnap | grep LISTEN\n```\n\n## 18. Examples\n\n### Run MariaDB server\n\n```\ndocker run --name some-mariadb -p 127.0.0.1:3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb\n```\n\nthe exposed MariaDB port used is 3307. to check it, run `netstat -tulnap | grep LISTEN`  \n\nto login to MariaDB server, run:\n\n```\nmysql -P 3307 -h 127.0.0.1 -u root -p\n```\n\nto SSH into the Docker container, run:\n\n```\ndocker exec -it some-mariadb bash\n```\n\nmore info https://hub.docker.com/_/mariadb\n\n### Useful links\n\n- https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04\n- http://phase2.github.io/devtools/common-tasks/ssh-into-a-container/\n- https://www.digitalocean.com/community/tutorials/how-to-share-data-between-the-docker-container-and-the-host\n- https://www.mirantis.com/blog/how-do-i-create-a-new-docker-image-for-my-application/\n- https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes\n- https://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d/46898038\n- https://serverfault.com/questions/924779/docker-cron-not-working\n- https://github.com/francarmona/docker-ubuntu16-apache2-php7/blob/master/Dockerfile\n- https://github.com/laradock/laradock\n- https://github.com/wsargent/docker-cheat-sheet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarweb%2Fdocker-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinarweb%2Fdocker-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarweb%2Fdocker-tutorial/lists"}