{"id":22503159,"url":"https://github.com/afa-farkhod/logs-management","last_synced_at":"2026-04-17T00:32:41.770Z","repository":{"id":196949685,"uuid":"697677174","full_name":"afa-farkhod/Logs-Management","owner":"afa-farkhod","description":"Docker multiple containers logs management into one *.json file","archived":false,"fork":false,"pushed_at":"2023-09-29T00:46:11.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T01:13:36.794Z","etag":null,"topics":["docker","docker-container","docker-image","dockerfile","json"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afa-farkhod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-28T08:47:09.000Z","updated_at":"2023-09-28T09:17:17.000Z","dependencies_parsed_at":"2023-09-28T10:58:34.604Z","dependency_job_id":null,"html_url":"https://github.com/afa-farkhod/Logs-Management","commit_stats":null,"previous_names":["af4092/logs-management","afa-farkhod/logs-management"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogs-Management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogs-Management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogs-Management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogs-Management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afa-farkhod","download_url":"https://codeload.github.com/afa-farkhod/Logs-Management/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245938232,"owners_count":20697008,"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":["docker","docker-container","docker-image","dockerfile","json"],"created_at":"2024-12-06T23:29:58.184Z","updated_at":"2026-04-17T00:32:36.748Z","avatar_url":"https://github.com/afa-farkhod.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logs-Management\nDocker multiple containers logs management into one *.json file\n\n## [Implementation](https://github.com/af4092/Logs-Management/tree/main/docker_logs_test)\n\n1. We first build two `node.js` source files one for `sender.js` which sends message to server and another one is `server.js` server which runs on `port:3001`.\n2. Then we make `Dockerfile` for both `sender.js` and `server.js` applications.  \n\n     - `Dockerfile.server` is as following:\n       \n       ```\n        # Use a base image\n         FROM node:latest\n        # Set the working directory\n         WORKDIR /app\n        # Copy the server file into the container\n         COPY server.js .\n        # Expose port 3001\n         EXPOSE 3001\n        # Run the Node.js server\n         CMD [\"node\", \"server.js\"]\n       ```\n       \n     - `Dockerfile.sender` is as following:\n  \n       ```\n       # Use a base image\n          FROM node:latest\n       # Set the working directory\n          WORKDIR /app\n       # Copy the sender file into the container\n          COPY sender.js .\n       # Run the message sender\n          CMD [\"node\", \"sender.js\"]\n       ```\n3. After making dockerfiles, we build `Docker image` from Dockerfiles with the following commands:\n\n   ```\n   $ docker build -t server:v0.1 -f Dockerfile.server .\n   $ docker build -t sender:v0.1 -f Dockerfile.sender .\n   ```\n\n     \u003cp align=\"center\"\u003e\n         \u003cimg src=\"https://github.com/af4092/Logs-Management/assets/24220136/5327a988-4ba0-44fa-81bf-dab47a16cd61.png\" alt=\"Image\"\u003e\n      \u003c/p\u003e\n\n4. Then we run the image inside the Docker container with the following commands:\n\n   ```\n   $ docker run -d -p 3001:3001 --name server server:v0.1\n   $ docker run -d --name sender sender:v0.1\n   ```\n   \n \u003cp align=\"center\"\u003e\n         \u003cimg src=\"https://github.com/af4092/Logs-Management/assets/24220136/2eb0fcc3-270e-4b3b-a154-75082ed29842.png\" alt=\"Image\"\u003e\n      \u003c/p\u003e\n\n5. We write script file to collect Docker containers logs into one `*.json` file. After running previous images in the Docker containers, we run `collect_logs.sh` script with the following command:\n\n     ```\n     $ ./collect_logs.sh\n     # then we get following answer from the terminal\n     $ Logs collected and saved to logs.json\n     ```\n\n6. Then we go inside the `logs.json` file to check the logs output:\n\n\u003cp align=\"center\"\u003e\n         \u003cimg src=\"https://github.com/af4092/Logs-Management/assets/24220136/5188f2aa-b0d7-4cca-ba22-10ce3c0ba502.png\" alt=\"Image\"\u003e\n      \u003c/p\u003e\n\n\n```diff\n- To Do:\n- As you've seen currently logs are being gathered only for one container and other container logs are not being tracked. So script source should be reconfigured to handle the issue\n```\n\n\n## [Reference]()\n\n- [Docker](https://docs.docker.com/) - official Docker documentation which shows how to make `image` file and run that particular image inside the `container`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafa-farkhod%2Flogs-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafa-farkhod%2Flogs-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafa-farkhod%2Flogs-management/lists"}