{"id":25394893,"url":"https://github.com/azersd/docker-tutorial","last_synced_at":"2025-09-11T06:34:52.540Z","repository":{"id":157296475,"uuid":"593096381","full_name":"AzerSD/docker-tutorial","owner":"AzerSD","description":"This repository is designed to provide a simple and effective container for C/C++ debugging on 42 Macs","archived":false,"fork":false,"pushed_at":"2023-04-01T17:38:32.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T17:00:17.836Z","etag":null,"topics":["archlinux","bash","containers","debugging","linux"],"latest_commit_sha":null,"homepage":"","language":null,"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/AzerSD.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":"2023-01-25T08:20:27.000Z","updated_at":"2023-10-13T17:43:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"be4149cb-f920-4fd6-ad4b-25d538161182","html_url":"https://github.com/AzerSD/docker-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AzerSD/docker-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzerSD%2Fdocker-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzerSD%2Fdocker-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzerSD%2Fdocker-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzerSD%2Fdocker-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AzerSD","download_url":"https://codeload.github.com/AzerSD/docker-tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzerSD%2Fdocker-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274589627,"owners_count":25312971,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["archlinux","bash","containers","debugging","linux"],"created_at":"2025-02-15T19:52:16.007Z","updated_at":"2025-09-11T06:34:52.515Z","avatar_url":"https://github.com/AzerSD.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-tutorial\nThis repository is designed to provide a simple and effective way to run Valgrind, C, C++ code. If you're a 42 student, this repo is a must-have resource for you to check for memory leaks in  your C/C++ code and perfecting your skills ;)\n\nTo create a Linux virtual environment with Docker on a Mac:\n\n1. Install Docker via the Managed Software Center.\n2. Clone the [42toolbox](https://github.com/alexandregv/42toolbox.git) repository and run the init_docker.sh file which is provided in this repo too.\n3. Check that Docker is running by checking the Docker icon in the top right corner. Note it may take some time.\n4. Create a directory called \"docker_image\" and a Dockerfile within it.\n5. In the Dockerfile, specify the instructions to build the Linux image by using the following:\n```bash\n# Sets the base image as the latest version of Arch Linux\nFROM archlinux:latest    \n\n# Updates the system's package databases and # Installing some packages (feel free to add packages that you need)\nRUN pacman -Syy\nRUN echo \"Y\" | pacman -Syu    \nRUN echo \"Y\" | pacman -S gcc git make vim sudo gdb valgrind zsh glibc python3 python-pip unzip wget curl cmake\n\n# Adds a new user \"asioud\" to the system and set a password for it\nRUN useradd -m -G users -s /bin/bash asioud   \nRUN echo \"asioud:strongpwd\" | chpasswd\n\n# Grants administrative privileges to the \"asioud\" user\nRUN echo 'asioud ALL=(ALL:ALL) ALL' | sudo EDITOR='tee -a' visudo   \n\n# Installs Pygments and Norminette for the new user\nRUN su - asioud -c \"pip install --user pygments norminette\"\n\n# Sets the system time zone to Europe/Berlin by copying the time zone information to the /etc/localtime file.\nRUN cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime \n\n# Sets the PATH environment variable to include the $HOME/.local/bin directory. (colour-valgrind doesn't work without it)\nRUN echo \"export PATH=$PATH:$HOME/.local/bin\" \u003e\u003e ~/.zshrc\n```\n\n6. In the terminal, navigate to the home directory and run `docker build -t arch:42 docker_image/` to build the Docker image.\n7. Running the script to get inside the Linux container:\nDetails are not provided in the original text.\n```bash\n#!/bin/bash\n\n# Get the name of the script\nme=`basename \"$0\"`\n\n# Strip the path to the home directory from the current working directory\nNEWVAR=${PWD#/Users/}\n\n# Get the absolute path to the script\nSCRIPTPATH=\"$( cd -- \"$(dirname \"$0\")\" \u003e/dev/null 2\u003e\u00261 ; pwd -P )\"\n\n# Construct a variable for the home directory in the container\nVAR=\"/home/${NEWVAR}\"\n\n# Check if an alias for the script exists in the .zshrc file\nif grep -q \"alias archlinux=\" $HOME/.zshrc; then\n    echo \"\"\nelse\n\t# If the alias doesn't exist, add it to the .zshrc file\n\techo \"alias archlinux=${SCRIPTPATH}/${me}\" \u003e\u003e $HOME/.zshrc \nfi\n\n# Run the Docker container\ndocker run -it \\\n  --dns 8.8.8.8 --dns 8.8.4.4 \\\n  --workdir=$VAR \\\n  -e \"DEBUGINFOD_URLS=https://debuginfod.archlinux.org\" \\\n  -e \"OSTYPE=archlinux\" \\\n  -e \"SHELL=/bin/zsh\" \\\n  -e \"TERM=xterm-256color\" \\\n  -e \"HOSTNAME=archlinux\" \\\n  --user=asioud \\\n  --privileged=true \\\n  --hostname=archlinux \\\n  -v $HOME:/home/asioud \\\n  arch:42\n```\nYou are now logged in your docker Linux container and you've mounted the mac's home directory into the arch's linux home directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazersd%2Fdocker-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazersd%2Fdocker-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazersd%2Fdocker-tutorial/lists"}