{"id":24769230,"url":"https://github.com/tsohledev/dorcas","last_synced_at":"2026-04-15T14:37:21.439Z","repository":{"id":184447165,"uuid":"671770561","full_name":"tsohleDev/dorcas","owner":"tsohleDev","description":"Dorcas is a simple to do app with SQLite DB to introduce ourselves to docker. This is the tutorial in the docker's official guide RTFM","archived":false,"fork":false,"pushed_at":"2023-08-04T18:33:35.000Z","size":1715,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-01T21:37:07.514Z","etag":null,"topics":["docker","nodemon-express","reactjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsohleDev.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-28T05:16:13.000Z","updated_at":"2023-08-15T02:36:13.000Z","dependencies_parsed_at":"2025-01-21T04:32:25.916Z","dependency_job_id":"ec9b75d3-5e67-4680-9a67-bbdcfbe44ab0","html_url":"https://github.com/tsohleDev/dorcas","commit_stats":null,"previous_names":["tsohledev/todockers","tsohledev/dorcas"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tsohleDev/dorcas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsohleDev%2Fdorcas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsohleDev%2Fdorcas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsohleDev%2Fdorcas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsohleDev%2Fdorcas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsohleDev","download_url":"https://codeload.github.com/tsohleDev/dorcas/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsohleDev%2Fdorcas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31846364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T13:28:40.153Z","status":"ssl_error","status_checked_at":"2026-04-15T13:28:29.396Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","nodemon-express","reactjs"],"created_at":"2025-01-29T02:52:58.990Z","updated_at":"2026-04-15T14:37:21.409Z","avatar_url":"https://github.com/tsohleDev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dorcas\n\u003e Express \u0026 SQLite To-Do App with Docker\n\n## Introduction\n\nDorcas is a learning repository designed to help developers understand the concepts of Docker by building and deploying a simple To-Do web application. The project utilizes the Express.js framework for the backend and SQLite as the database. Through this repository, you will gain hands-on experience creating Docker images, containers, volumes, and Docker Compose, enabling you to efficiently manage your app's development, deployment, and local environment setup.\n\n## Getting Started\n\n### Prerequisites\n\n- [Docker](https://www.docker.com/get-started) must be installed on your system.\n- [Docker Compose](https://docs.docker.com/compose/install/) also should be installed\n- [DockerHub](https://hub.docker.com/) Have an account\n- **Bash**. We will be running all our scripts using bash\n\n### Clone to your local machine\n\nClone this repository to your local machine using the following command:\n\n   ```bash\n   git clone https://github.com/tsohledev/dorcas.git\n   cd toDockers\n   ```\n## Dockerize \n\n### Simple Container\n\u003e Lets just get our feet wet and spin one up to test the basic commands\n\n1. Build the image from the [Dockerfile]('./Dockerfile')\n    ```bash\n    # raising -t which means tag allows your to give the container a name in this case 'to-dockers'\n    # the parameter of the build command is a the path to your Dockerfile, thus '.' specifys the same directory\n    docker build -t to-dockers .\n    ```\n2. run the container from the image\n    ```bash\n    # the -p flag allows you to add an additinal parameter '127.0.0.1:3000:3000' for a port mapping between the host and the container\n    # the -d flag detaches the container terminal from your terminal\n    docker run -dp 127.0.0.1:3000:3000 to-dockers\n    # the parameter here is the name of the image\n    ```\n3. confirm it running\n    ```bash\n        docker ps\n        # you should see an image 'to-dockers'\n    ```\n4. stop and delete the container\n    ```bash\n        # -f is to force the delete even if the container is running\n        # the parameter is the id of the container that you got when you ran the 'docker ps' command\n        docker rm -f \u003cid\u003e\n    ```\n### Named Volume Mounting\n\u003e Lets mount a volume from the host to the sql db file\n\n1. Create the named volume **todo-db**\n\n```bash\n    docker volume create todo-db # Create volume\n    docker volume inspect todo-db # Check the volume's metadata\n```\n\n2. Create a container with the volume mounted the sqlite folder `/etc/todos`\n\n```bash\n    # -v raised to allow mounting parameter 'volume_name:container_path'\n    docker run -dp 127.0.0.1:3000:3000 -v todo-db:/etc/todos to-dockers\n```\n\nNow insert some todos into your app stop and remove your container spin up again while mounting the db to the volume again. It should persist the data.\n\n### Bind Mounting\n\u003e No to \"It works on my local machine', Yes to \"It works in the container\"\n\nBecause we are in `development` mode, we wont be using our docker file to build an image, but rather a base image with node only and **bind** the host's ```pwd``` to the container... say in ```/src```\n\n#### Run a container bound to the host\n\n```bash\n    docker run -dp 127.0.0.1:3000:3000 / \n    -w /app / \n    --mount type=bind,src=\"$(pwd)\",target=/src / \n    node:18-alpine / \n    sh -c \"yarn install \u0026\u0026 yarn run dev\"\n```\n\nWe raised the flag `-w` to specify the working directory, `--mount` with type bind to do the binding, then run the `sh` script to install the dependencies and to run the script **dev** which runs the server using [nodemon](https://www.npmjs.com/package/nodemon). Happy coding! Remember to stop the container\n\n### + Containers\n\n\u003e Let add a MySql database container\n\n1. Create a network\n\n```bash\n    docker network create todo-app\n```\n\n2. Run a mysql container connected to the network\n\n```bash\n    # network flag to connect the network todo-app\n    # network-atlias flag raised so we can add\n    # -e flag for enviromental variables 'database name and root password'\n    # we run the mysql image from dockerhub\n    docker run -d \\\n     --network todo-app --network-alias mysql \\\n     -v todo-mysql-data:/var/lib/mysql \\\n     -e MYSQL_ROOT_PASSWORD=secret \\\n     -e MYSQL_DATABASE=todos \\\n     mysql:8.0\n```\n\nInspect your database\n\n```bash\n    # exec is to execute a script in the container\n    # -i to make it interactive, i.e keep the bash open\n    # -t tty/terminal gets a pseudo terminal to interact with the container\n    # 'mysql -u root -p' the script to be executed inside that connects to the mysql server\n    docker exec -it \u003cid\u003e mysql -u root -p\n```\n\nLog in with the password from your enviromental variable `MYSQL_ROOT_PASSWORD` and check the databases\n\n```bash\n    mysql\u003e SHOW DATABASES;\n```\n\nIs all good?\n\n```bash\n    mysql\u003e exit\n```\n\n3. Connect the database\n\n\u003e Lets use [nicolaka/netshoot](https://github.com/nicolaka/netshoot) to interconect\n\n```bash\n    # start a new container from the nicolaka/netshoot connected to the network todo-app\n    docker run -it --network todo-app nicolaka/netshoot\n\n    # run the node app connected to the network\n    docker run -dp 127.0.0.1:3000:3000 \\\n    -w /app -v \"$(pwd):/app\" \\\n    --network todo-app \\\n    -e MYSQL_HOST=mysql \\\n    -e MYSQL_USER=root \\\n    -e MYSQL_PASSWORD=secret \\\n    -e MYSQL_DB=todos \\\n    node:18-alpine \\\n    sh -c \"yarn install \u0026\u0026 yarn run dev\"\n```\n\nThe app should have connected to the external database in the different container, you can even check by adding some todos in the browser and checking the **logs** if the database is indeed connected.\n\nCheck also in the mysql container if the data is written \n```bash\n    docker exec -it \u003cid\u003e mysql -p todos\n```\n\n```bash\n    mysql\u003e select * from todo_items;\n```\n\n### Docker Compose\n\u003e Lests ease the process of configuring the containers\n\n1. You must have the [docker-compose.yaml](./docker-compose.yaml)\n\n2. Spin up the stack \n\n```bash\n    # up command specifies that we run all the services\n    docker compose up -d\n```\n\nYou can check if the services are running by the `docker compose logs -f`\n\nAll is well? shut it down now `docker compose down`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsohledev%2Fdorcas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsohledev%2Fdorcas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsohledev%2Fdorcas/lists"}