Testing environments on docker

If you are constantly testing/trying new software is cleaner and safer to do so in a new enviornment. For this docker is very handy.

Run a Debian container and enter it

docker run -p 3000:3000 -it debian:latest /bin/bash
apt update && apt upgrade -y
apt install -y git wget nodejs npm build-essential

If go is required:

wget https://go.dev/dl/go1.21.1.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

Other useful enviornments for simpler tasks

docker run -it golang:latest /bin/bash
docker run -it node:latest /bin/bash

a few random docker useful commands

docker build . -t mynewimage

docker run -d -t --name letsrock imagename

docker exec -it letsrock bash1

docker images

docker ps

docker-compose up -d

docker-compose up -d mycontainer

To view space used by docker: docker system df

docker system prune -a

To delete all volumes using the following command: docker volume rm $(docker volume ls -q)

View logs docker logs imagename -f

Create external network for traefik docker network create --driver=bridge --attachable --internal=false traefik_proxy Output: 7aa05528d00064911164455c18d06a920885c1011fb1e9183d6f4ef437aae31f

docker stats


  1. Some containers may not have bash installed. To add it add the following line to the Dockerfile RUN apk update && apk add bash. You can also just run from the command line docker exec -it mycontainer apk update and docker exec -it mycontainer apk add bash