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 imagedocker images: List local imagesdocker build: Build an image from a Dockerfiledocker rmi: Remove a imagedocker load: Import an imagedocker save: Export an image
Container management commands:
docker start/stop/restart: Control container lifecycledocker exec: Execute commands in a running containerdocker attach: Connect to a running cnotainerdocker ps: List containers (use-afor all)docker top: Show processes in a containerdocker 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:
- https://github.com/coder/code-server/issues/6627
- https://blog.csdn.net/csh1807266489/article/details/130115066
Set environment variable:
export PASSWORD="wuboy2001"
Enable service:
systemctl enable --now code-server@root
Additional reference: