{"id":21043807,"url":"https://github.com/yoursrijit/docker-end-to-end","last_synced_at":"2025-03-13T22:08:40.799Z","repository":{"id":252966665,"uuid":"841895010","full_name":"yourSrijit/Docker-end-to-end","owner":"yourSrijit","description":"My Notes on Docker end to end | Devops","archived":false,"fork":false,"pushed_at":"2024-08-13T15:22:34.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T17:25:26.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/yourSrijit.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":"2024-08-13T09:03:00.000Z","updated_at":"2024-08-13T15:22:38.000Z","dependencies_parsed_at":"2024-08-13T18:43:25.069Z","dependency_job_id":null,"html_url":"https://github.com/yourSrijit/Docker-end-to-end","commit_stats":null,"previous_names":["yoursrijit/docker-end-to-end"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yourSrijit%2FDocker-end-to-end","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yourSrijit%2FDocker-end-to-end/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yourSrijit%2FDocker-end-to-end/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yourSrijit%2FDocker-end-to-end/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yourSrijit","download_url":"https://codeload.github.com/yourSrijit/Docker-end-to-end/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489897,"owners_count":20299001,"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-11-19T14:14:22.415Z","updated_at":"2025-03-13T22:08:40.761Z","avatar_url":"https://github.com/yourSrijit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker In One Shot - Part 1\n---\n## Creating Container \n`docker run -it \u003cImage_Name\u003e`\nit check is ubuntu is locally presrnt or not. if not it will pull from hub.docker\n\n## What is image and container\n- Docker Image\nDefinition: A Docker image is a read-only template that contains the instructions for creating a Docker container. It includes everything needed to run an application, including the code, runtime, libraries, environment variables, and configuration files.\n\nCreation: Images are typically built from a Dockerfile, which is a text file that contains a series of commands and instructions to assemble the image. For example, a Dockerfile might specify a base image (like an Ubuntu or Alpine Linux image), install necessary packages, and set up the application environment.\n\nImmutability: Once an image is created, it does not change. If you need a new version, you create a new image. Images can be shared and distributed via Docker registries, such as Docker Hub.\n\n- Docker Container\nDefinition: A Docker container is a runtime instance of a Docker image. It is a lightweight, standalone, and executable package that runs the application and its dependencies. Containers are isolated from each other and from the host system, but they share the OS kernel with other containers.\n\nLifecycle: Containers are created from images and can be started, stopped, moved, and deleted. When a container is started, it uses the image as a blueprint and creates a writable layer on top of the image's read-only layers.\n\nPersistence: Changes made inside a running container do not affect the original image. However, you can commit changes from a container to create a new image, which can then be used to launch new containers with those changes.\n\n## Port Mapping\nPort mapping in Docker is a feature that allows you to expose and map ports on a Docker container to ports on the Docker host. This is essential for making services running inside containers accessible from outside the container, such as from your local machine or other networked devices.\nWhen a container runs a service that listens on a specific port (like a web server running on port 80), this port is isolated inside the container. Port mapping allows you to map this internal port to a port on the Docker host, so you can access the service from outside the container.\n\n`docker run -p \u003chost_port\u003e:\u003ccontainer_port\u003e \u003cimage_name\u003e`\n\nYou can map multiple ports by specifying multiple -p options also add env value using -e\n```\ndocker run -p 8080:80 -p 443:443 my-web-server\n\nAdding environment variables\ndocker run -p 8080:80 -p 443:443 -e key1=value1 key2=value2 my-web-server\n```\n\n## Dockerization of NodeJS Application\n\n- 1.Create a server\n- 2.Create a Dockerfile\n```\n        FROM ubuntu\n\n        RUN apt-get update\n        RUN apt-get install -y curl\n        RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -\n        RUN apt-get upgrade -y\n        RUN apt-get install -y nodejs\n\n        COPY package.json package.json\n        COPY package-lock.json package-lock.json\n        COPY server.js server.js\n\n        RUN npm install\n\n        ENTRYPOINT [ \"node\", \"server.js\" ]\n```\n- 3. Run this command to build the image\n    `docker build -t my-node-server . `\n    ```\n    this will generate a image in docker\n- 4. Run that server from cmd  \n    ```\n    docker run -it my-node-server\n    docker run -it -p 4000:4000 my-node-server\n    ```   \n\n ## Publish yout image on Docker Hub   \n - 1. Create a repo on Docker hub\n - 2. Build a image locally with the same name as repo\n    `docker build -t yoursrijit/my-node-server .`\n - 3. After creating the image login in docker locally and push the image into hub.docker\n        ```\n        docker login\n        docker push yoursrijit/my-node-server\n        ```   ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoursrijit%2Fdocker-end-to-end","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoursrijit%2Fdocker-end-to-end","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoursrijit%2Fdocker-end-to-end/lists"}