Docker Snippets
Debugging a build
Add this to your docker image build command:
docker build --no-cache --progress=plain
MitM proxy!
docker run --rm -it -v $PWD/.mitmproxy:/home/mitmproxy/.mitmproxy -p 8080:8080 mitmproxy/mitmproxy
Alpine
This'll create a alpine linux container and install the basic tools
docker run -it --rm -v "${PWD}:/test:rw" --name alpine alpine sh
apk add curl git gpg openssh vim
Firebase
docker run -it --rm -v "${PWD}:/app:rw" -w /app -p 3000:3000 --user node --name node node:21 bash
npm install -g firebase-tools
firebase login --no-localhost
Permission error
# 1. Create a new dir
mkdir ~/.npm-global
# 2. Config NPM to use new path
npm config set prefix ~/.npm-global
# 3.Add new path to the profile
export PATH=~/.npm-global/bin:$PATH
# 4. Profile reload
source ~/.profile
NodeJS
docker run -it --rm -v "${PWD}:/app:rw" -w /app -p 3000:3000 --user node --name node node:17 bash
Python
docker run -it --rm -v "${PWD}:/app:rw" -w /app -p 5000:5000 --user python --name python python bash
React
Creating a new project
The following piece of code generates a basic React application
docker run -it --rm -v "${PWD}:/app:rw" -w /app --user node --name node node:14 bash
npx create-react-app bahlinktri
Running a dev project
Docusaurus
Creating a new project
## Create the project directory and get into it
mkdir <project_name>
## Start a Docker container
docker run -it --rm -v "${PWD}:/app:rw" -w /app -p 3000:3000 --user node --name node node:17 bash
### Inside the container, create a Docusaurus App
npx -y create-docusaurus@latest <project_name> classic --package-manager npm
## Then, exit the container, cd into the project dir, run docker and start the App
cd <project_name>
docker run -it --rm -v "${PWD}:/app:rw" -w /app -p 3000:3000 --user node --name
docusaurus node:17 bash
npx docusaurus start -h 0.0.0.0
https://docusaurus.io/docs/next/docs-introduction#docs-only-mode