What is Code-Server
First of all, programmer friends must have used VS Code, a lightweight and advanced editor from Microsoft. It has a rich plug-in library and supports compilation and operation of various languages. The Code-Server introduced in this article is a product developed by coder based on Microsoft's open source Visual Studio Code, which can run VS Code on any machine anywhere and access it in a browser.
Coder official website: https://coder.com/
Code-Server project address : https://github.com/coder/code-server
Docker install Code-Server
Installation Environment
- Linux:CentOS 7
- Docker:20.10.10
View command:
# Linux查看版本当前操作系统发行版信息
cat /etc/redhat-release
# 显示Docker版本
docker -v
Running effect:
The above is my environmental information, and then I start to enter the topic of installing Code-Server~
Pull the Code-Server image
Search for Code-Server mirrors
docker search code-server
Select codercom/code-server VS Code in the browser
mirror – this is the official mirror
pull mirror
docker pull codercom/code-server
Waiting for the pull...
The pull is complete ~
check whether the image is pulled successfully
. You can see that the pull has been successful, and the image is about 1.5GB.
Create and run the Code-Server container
Create a container
docker run -d -u root -p 9999:8080 --name code-server -v /mydata/code:/home/code codercom/code-server
Parameter Description:
- -d run in the background
- -u Use the root user to log in to the container to avoid insufficient permissions
- -p port mapping
- --name container name
- -v Mount the data volume (code-server is stored under /home/code in the container directory by default, I mapped this directory to the local /mydata/code directory)
After the creation is successful, it will automatically run
to check whether it runs successfully.
docker ps
The display shows codercom/code-server
that the startup was successful
browser access
View IP address
- If you are using a cloud server, you can use the IP of the cloud service
- If you are using a server built by a virtual machine, use the
ifconfig
command to view the IP
ifconfig
Access IP: 9999
The access is successful. At this time, it will ask for a password to access, and this password is randomly generated by Code-Server.
View the initialization password of Code-Server:
View configuration files
docker exec -it code-server cat ~/.config/code-server/config.yaml
Modify the default access password, otherwise the default generated password is too long to remember
open a file
Shortcut key: Ctrl+O
to select /root/.config/code-server/config.yaml
Modify Password
The password will not take effect immediately after the password is changed, and the container needs to be restarted
restart the container
docker restart code-server
After restarting, enter the new password to enter.
It is recommended to prepare a cloud service to install Code-Server so that you can code on any device anywhere
iPhone
Prepare the Serverditer
software ,
select local Self hosted server (Free)
, enter the configuration information, and click on the Save
connection is successful
. At this time, you can code on the mobile phone.
Of course, you can also directly access it on the browser.
Android phone
Android phone preparation VHEditor
software
VHEditor project address: https://github.com/vhqtvn/VHEditor-Android
Download VHEditor software:
Open https://github.com/vhqtvn/VHEditor-Android/releases/tag/v1.6.0
and click directly after downloading and installing. INSTALL SERVER
Wait for installation...
Enter the server IP address + port number
and click START EDITOR
Wait... The
connection is successful