{"id":19594238,"url":"https://github.com/julioaranajr/06_docker.md","last_synced_at":"2026-05-09T05:07:54.653Z","repository":{"id":93961867,"uuid":"544468989","full_name":"julioaranajr/06_Docker.md","owner":"julioaranajr","description":"Hand on Labs [Introduction to Containers]","archived":false,"fork":false,"pushed_at":"2024-07-02T13:20:19.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T07:12:58.191Z","etag":null,"topics":["containers","docker","docker-container","kubernetes","kubernetes-deployment","kubernetes-setup","minikube","nginx"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":false,"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/julioaranajr.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":"2022-10-02T15:02:17.000Z","updated_at":"2024-07-02T13:20:23.000Z","dependencies_parsed_at":"2025-01-09T07:12:09.349Z","dependency_job_id":"d90b2131-083f-4c01-9676-c37feb925ccd","html_url":"https://github.com/julioaranajr/06_Docker.md","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julioaranajr%2F06_Docker.md","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julioaranajr%2F06_Docker.md/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julioaranajr%2F06_Docker.md/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julioaranajr%2F06_Docker.md/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/julioaranajr","download_url":"https://codeload.github.com/julioaranajr/06_Docker.md/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240867750,"owners_count":19870469,"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":["containers","docker","docker-container","kubernetes","kubernetes-deployment","kubernetes-setup","minikube","nginx"],"created_at":"2024-11-11T08:42:41.635Z","updated_at":"2026-05-09T05:07:54.615Z","avatar_url":"https://github.com/julioaranajr.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"Hand on Labs [Introduction to Containers]\n\n**Tasks**:\n- Task 0: Prerequisites\n- Task 1: Run simple containers\n- Task 2: Package your custom application using Docker\n- Task 3: Running your application on Kubernetes locally\n\nTask 0: Prerequisites\n\nFirst, you need to install Docker.\n\nInstall Docker Desktop on Mac\n\nDocker Desktop is an easy-to-install application for your Mac, Linux, or Windows environment \nthat enables you to build and share containerized applications and microservices.\n\nIt provides a simple interface that enables you to manage your containers, applications, and \nimages directly from your machine without having to use the CLI to perform core actions.\n\nWhat's included in Docker Desktop?\nWhat are the key features of Docker Desktop?\n\u003e - Docker Engine\n\u003e - Docker CLI client\n\u003e - Docker Buildx\n\u003e - Docker Compose\n\u003e - Docker Content Trust\n\u003e - Kubernetes\n\u003e - Credential Helper\n\nDocker Desktop works with your choice of development tools and languages and gives you access \nto a vast library of certified images and templates in Docker Hub. This enables development teams \nto extend their environment to rapidly auto-build, continuously integrate, and collaborate using \na secure repository.\n\n[Docker Documentation](https://docs.docker.com/desktop/mac/install/)\n\nThen launch the Docker app and confirm your password for privileged access. (Might need a restart)\n\nRun Docker Desktop Application\n```bash\nopen /Applications/Docker.app\n```\n\nRun a simple nginx container\n\n1. Check if Docker was installed successfully:\n\nChech your Version\n```bash\ndocker version\n```\n\n2. Run the following command:\n\nCommand to pull a image of nginx from Docker Hub\n```bash\ndocker run -d -p 80:80 --name webserver nginx\n```\n\nWhen `nginx:latest` image could not be found locally, Docker automatically _pulls_ it form Docker Hub.\n\nYou’ll notice a few flags being used. Here’s some more info on them:\n\n- -d - run the container in detached mode (in the background)\n- -p 80:80 - map port 80 of the host to port 80 in the container\n- nginx - the image to use\n\n\n3. Try to access a container on localhost:80 on your machine: http://127.0.0.1:80/\n\n\n4. Check how long it will take to start a new container with a new image:\n\nRun this command to create a new container\n```bash\ndocker run -d -p 8080:80 --name webserver2 nginx\n```\n\nThe image was downloaded already, so this container started faster.\n\n\n5. You can run bash commands inside a Linux container:\n\nThis command open an interactive console in the container\n```bash\ndocker exec -it webserver /bin/bash\n```\n\nDocker exec runs a command in a running container and the switch -it opens an interactive console\n\n6. Stop containers and remove the image:\n\nCommand to STOP containers before remove it\n\n```bash\ndocker stop webserver\n```\n\n```bash\ndocker stop webserver2\n```\n\nCommand to REMOVE containers\n\n```bash\ndocker rm webserver\n```\n\n```bash\ndocker rm webserver2\n```\n\nCommand to REMOVE IMAGES in Docker Hub\n\n```bash\ndocker rmi webserver\n```\n\n```bash\ndocker rmi webserver2\n```\n\nPackage your custom application using Docker\n\nYou can create an image for your application by using Dockerfile. It contains a list of instructions \nto build images such as installing a package, downloading source code, using a base image.\n\n1. Create a new folder:\n\nCreate the directory\n```bash\nmkdir web-image\n```\n\nAccess to the directory\n```bash\ncd web-image\n```\nCreate a file for the example website:\n```bash\ncode index.html\n```\n```html\n\u003chtml\u003e\n\u003cbody\u003e\n\u003ch1\u003eHello world\u003c/h1\u003e\n\u003cp\u003eThis is a Talent-Academy Exercise\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n3. Create a Dockerfile and add the following:\n\n**Dockerfile** is a text file that contains a list of instructions needed to build a given image. For example: install a package, download source code, use a base image.\n\n```bash\ncode Dockerfile\n```\n\n```dockerfile\nFROM ubuntu\nRUN apt-get update\nRUN apt-get install nginx -y\nCOPY index.html /var/www/html/\nEXPOSE 80\nCMD [\"nginx\", \"-g\", \"daemon off;\"]\n```\n\n- [FROM](https://docs.docker.com/engine/reference/builder/#from) specifies the base image to use as the starting point for this new image you're creating.\n- [RUN](https://docs.docker.com/engine/reference/builder/#run) Executes a command on top of an existing layer and creates a new resulting layer\n- [COPY](https://docs.docker.com/engine/reference/builder/#copy) Copies files and directories from a source (host executing build command) to a destination (Container image)\n\n4. Build Image\n\nRun `docker image build` command to create a new Docker image using the instructions in your Dockerfile.\n\n- `--tag` allows us to give the image a custom name. It usually consists of your Docker Hub username, the application name, and a version.\n- `.` tells Docker to use the current directory as the build context\n\n**Be sure to include the period (`.`) at the end of the command.**\n\n```bash\ndocker build -t \u003cimage-name\u003e --tag \u003cyourusername\u003e/\u003cimage-name\u003e:1.0 .\n```\n\n5. (Optional) Push your image to Docker Hub\n\nList local images:\n```bash\ndocker images\n```\n\nLog in to Docker Hub:\n```bash\ndocker login --username \u003cyourusername\u003e\n```\n\nPush the image to your repository in Docker Hub:\n```bash\ndocker push \u003cyourusername\u003e/\u003cimage-name\u003e:1.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulioaranajr%2F06_docker.md","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulioaranajr%2F06_docker.md","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulioaranajr%2F06_docker.md/lists"}