{"id":19684939,"url":"https://github.com/boolfalse/node-docker","last_synced_at":"2026-05-15T09:11:47.475Z","repository":{"id":203946651,"uuid":"363528736","full_name":"boolfalse/node-docker","owner":"boolfalse","description":"Node.js with Docker (project sample)","archived":false,"fork":false,"pushed_at":"2023-10-27T10:28:50.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-10T06:58:54.706Z","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/boolfalse.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}},"created_at":"2021-05-01T23:38:12.000Z","updated_at":"2023-10-27T10:30:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"33ebeca7-53ca-4b3d-9346-4ed1ed4805b3","html_url":"https://github.com/boolfalse/node-docker","commit_stats":null,"previous_names":["boolfalse/node-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fnode-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fnode-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fnode-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolfalse%2Fnode-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boolfalse","download_url":"https://codeload.github.com/boolfalse/node-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240993432,"owners_count":19890418,"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-11T18:19:23.291Z","updated_at":"2026-05-15T09:11:42.414Z","avatar_url":"https://github.com/boolfalse.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Node.js with Docker project sample\n\n\n### Prerequisites:\n\n- Node.js\n- Docker\n- Docker-compose\n\n\n### Basic info:\n\n- Containers are isolated from each other and bundle their own application, tools, libraries and configuration files; they can communicate with each other through well-defined channels.\n- The difference between a container and a virtual machine is that containers are not based on a hardware virtualization, but on OS-level virtualization.\n- The advantage of containers is that they are lightweight and portable.\n\n\n### Commands:\n\n- Install Docker on Linux:\n```bash\nsudo apt update\nsudo apt install docker.io\n# restart the machine\nsudo apt update\nsudo apt install docker-compose\n```\n\n- Pull an image from dockerHub:\n```bash\ndocker pull \u003cIMAGE_NAME\u003e:\u003cTAG\u003e\n# example postgres latest version:\ndocker pull postgres:latest\n# example node.js version 14:\ndocker pull node:14\n```\n\n- Building a docker image from the Dockerfile:\n```bash\n# by default it will be find the file named \"Dockerfile\"\ndocker build . --tag node-server-container\n# if there is no Dockerfile in the current directory, you can specify the path to the Dockerfile like this:\ndocker build ./path/to/Dockerfile --tag node-server-container\n```\n\n- See docker images:\n```bash\ndocker images -a\ndocker image ls -a\n```\n\n- Delete images:\n```bash\ndocker image rm \u003cIMAGE_ID\u003e\ndocker rmi \u003cIMAGE_ID\u003e\n```\n\n- Create/Build an image with specifying the image name (tag):\n```bash\ndocker build . -t node-server\n```\n\n- Run a container with name \"node-server-container\" by the image name:\n```bash\ndocker run -d --name node-server-container node-server-image\n# \"-d\" means that we'll detach after running the command\n# by default it will read the \"node-server-image\" from the local machine\n# but if it will not find it, it will try to find it in the dockerHub remote repository\n```\n\n- See containers:\n```bash\ndocker ps -a\ndocker container ls -a\n```\n\n- Delete container:\n```bash\n# stop and delete the container\ndocker stop \u003cCONTAINER_ID\u003e\ndocker rm \u003cCONTAINER_ID\u003e\n# delete force:\ndocker rm \u003cCONTAINER_ID\u003e -f\n```\n\n- Create \".dockerignore\" for ignoring files and folders when building the docker image\n\n- Run our container from created image:\n```bash\n# first number is the public port (http://localhost:5001)\n# second number is the docker container internal port\ndocker run -p 5001:5000 -d --name node-server-container node-server-image\n```\n\n- Login to \"node-server-container\" container using \"bash\" editor\n```bash\n# \"-it\" means the interactive mode\ndocker exec -it node-server-container bash\n# \"exit\" to exit from the container\n\n# or run a command inside the container\ndocker exec -it node-server-container \u003cCOMMAND\u003e\n# example:\ndocker exec -it node-server-container npm run migrate\n```\n\n- In this step when we'll change something in our app, (for example in \"index.js\"),\n  it will not affect on container files which we've already run.\n\n- Create docker-compose.yml with setting the environment variables and volumes:\n```bash\n# start the compose services\ndocker-compose up -d --build\n\n# execute a command inside the container\ndocker exec \u003cCONTAINER_ID\u003e npm run migrate\ndocker exec \u003cCONTAINER_ID\u003e npm run seed\n\n# test via connecting to the Postgres database\n# (if it's publicly available for external connections)\npsql -h localhost -p 4321 -U postgres\n\\c postgres\n\\dt\nSELECT * FROM users;\n\\q\n# or test via server\ncurl http://localhost:5001/users\n\n# stop the compose services\ndocker-compose down\n```\n\n- See volumes:\n```bash\ndocker volume ls -a\n```\n\n### Resources:\n\n- [Classsed: Docker Tutorial (+ Node \u0026 Postgres setup)](https://www.youtube.com/watch?v=Dm0CmZz-QyI)\n- [Complete Source Code](https://github.com/hidjou/classsed-docker-tutorial/tree/done)\n\n- [Can’t delete docker image with dependent child images](https://stackoverflow.com/questions/38118791/can-t-delete-docker-image-with-dependent-child-images/43463968#43463968)\n- [Postgres, Docker \u0026 Node.js - Password authentication failed (Connection refused or psql: FATAL: role \"root\" does not exist)](https://stackoverflow.com/questions/43532280/postgres-docker-node-js-password-authentication-failed-connection-refused)\n- [psql: FATAL: password authentication failed for user \"postgres\"](https://github.com/sameersbn/docker-postgresql/issues/112)\n- [Postgres, Docker \u0026 Node.js - Password authentication failed (Connection refused or psql: FATAL: role \"root\" does not exist)](https://stackoverflow.com/questions/43532280/postgres-docker-node-js-password-authentication-failed-connection-refused?noredirect=1\u0026lq=1)\n- [How to fix an error: password authentication failed for the user in PostgreSQL](https://hassanannajjar.medium.com/how-to-fix-error-password-authentication-failed-for-the-user-in-postgresql-896e1fd880dc)\n- [postgres on dockerhub](https://hub.docker.com/_/postgres)\n\n\n### TODOs:\n\n- Setup Postgres container with another user and password.\n\n\n### Author:\n\n- [BoolFalse](https://boolfalse.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboolfalse%2Fnode-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboolfalse%2Fnode-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboolfalse%2Fnode-docker/lists"}