code-server is vscode running on a remote server, accessibale throught the browser.
Code server is a remote vscode that can be built on the server, and we can directly access it with browser. The original intention was to write blog directly in the browser instead of having to open vscode every time. Later, it was found that code server can also be used on iPad, and the compatibility is good
The advantage of using docker to build code server is that it can be built quickly, but there is no way to use the environment and configuration of the host. If configuration is required, it needs to be configured from the beginning.
Docker compose is one of the docker official orchestration projects, which is responsible for rapid deployment of distributed applications. Using docker compose, our docker commands can be reused or constitute more advanced configuration files.
mkdir /usr/local/code-serverIt can be used to store the new project and open the new folder in any location
cd /usr/local/code-server, create and edit docker compose
touch docker-compose.yml && vim docker-compose.yml
version: "3" services: code-server: container_name: code-server image: codercom/code-server ports: - "8080:8080" volumes: - "/usr/local/code-server/project:/home/coder/project" environment: PASSWORD: <password> restart: always
The front is the host port, which can be changed to the required port, and the back is the port in the container, which cannot be changed
Data volume: new folder +’project ‘in front
The container can be restarted automatically after accidental shutdown
#In the cocker-compose.yml directory Docker compose up ## starts normally Docker compose up - D ## background startup # kill docker container Docker PS # view the corresponding code server ID docker kill <id>