Created
May 10, 2023 09:03
-
-
Save syedmhashim/b0071f15f53a588f498106b690b5c47d to your computer and use it in GitHub Desktop.
Run docker commands in a docker container with your current directory mounted into the container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.3" | |
services: | |
docker: | |
image: docker:20.10.16 | |
restart: always | |
volumes: | |
- $PWD:/home/ | |
environment: | |
- DOCKER_TLS_VERIFY= | |
- DOCKER_TLS_CERTDIR= | |
- ENV_MODE=local | |
- DOCKER_HOST=tcp://daemon:2375 | |
entrypoint: "/bin/sh -c \"tail -f /dev/null\"" | |
depends_on: | |
- daemon | |
daemon: | |
image: docker:20.10.16-dind | |
privileged: true | |
environment: | |
- DOCKER_TLS_VERIFY= | |
- DOCKER_TLS_CERTDIR= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may want to add the following function to your
.bashrc
or.zshrc
file:Where you need to replace
$PATH_TO_FILE
with the actual path where thedind.docker-compose.yaml
file is stored. Once this is done, you can run the follow the steps below to open your current working directory inside a docker container for debugging:run_in_docker
docker ps -a
.Note the name of the docker container.
docker exec -it <container_name> sh