Running codeserver within a Docker container

Setting up codeserver in a Docker container

Pulling and configuring the Docker environment

docker pull ubuntu:20.04

sudo apt update
sudo apt install wget

sudo apt install net-tools
sudo apt update
sudo apt install git

apt install curl

Common Docker commands:

  • docker run: Create a container from an image
  • docker images: List local images
  • docker build: Build an image from a Dockerfile
  • docker rmi: Remove a image
  • docker load: Import an image
  • docker save: Export an image

Container management commands:

  • docker start/stop/restart: Control container lifecycle
  • docker exec: Execute commands in a running container
  • docker attach: Connect to a running cnotainer
  • docker ps: List containers (use -a for all)
  • docker top: Show processes in a container
  • docker rm: Delete a container

Create and make executable:

touch setup_imx6ull_container.sh
chmod 777 setup_imx6ull_container.sh
./setup_imx6ull_container.sh

Container setup script (setup_imx6ull_container.sh):

#!/bin/bash

MOUNT_DIR=/home/$USER
if [ ! -z "$1" ]; then
  MOUNT_DIR=$1
fi

CONTAINER_NAME=$USER.imx_6ull_docker
if [ ! -z "$2" ]; then
  TARGET=$2
  CONTAINER_NAME=$USER.$TARGET.imx_6ull_docker
fi

IMAGE="ubuntu:20.04"
OLD_ID=`docker ps -aq -f name=$CONTAINER_NAME`
ID_runing=`docker ps -aq -f name=$CONTAINER_NAME -f status=running`
if [ -z "$OLD_ID" ]; then
        docker run -itd --name=$CONTAINER_NAME -p 8095:8080  -v $MOUNT_DIR:/mnt/ $IMAGE
else
        if [ -z "$ID_runing" ]; then
        docker start $OLD_ID
        fi
fi
docker exec -it $CONTAINER_NAME bash

Installing and configuring codeserver

To preview installation with out executing:

curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run

Actual installation:

curl -fsSL https://code-server.dev/install.sh | sh

The same command can also be used for updates.

Configure access settings via ~/.config/code-server/config.yaml:

bind-addr: 0.0.0.0:8080
auth: password
password: qwerqwdjoapmdaodo
cert: false

The default address is 127.0.0.1:8080. Change it to 0.0.0.0:8080 to allow LAN access.

The password field sets the login credential which can be customized.

For LAN access, open a browser and navigate to http://HOST_IP:8080.

Example IP: 192.168.10.190:8080

Reference issues:

Set environment variable:

export PASSWORD="wuboy2001"

Enable service:

systemctl enable --now code-server@root

Additional reference:

Tags: docker codeserver Ubuntu development-environment remote-access

Posted on Wed, 10 Jun 2026 18:39:47 +0000 by vipes