mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
164 words
1 minute
Configure Docker + code-server on Alibaba Cloud to Build an Online Compiler
2022-07-06

Alibaba Cloud: Configure Docker + code-server to enable an online compiler#

1. Install Docker#

  1. Install Docker

Docker has two branch versions: Docker CE and Docker EE, i.e., Community Edition and Enterprise Edition. This experiment uses Docker CE.

  • Install Docker dependencies and add Docker’s software repository information
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • Install Docker
yum makecache fast //更新yum缓存
yum -y install docker-ce
docker info //查看安装状态
  • Start the Docker service
systemctl start docker //启动docker服务
systemctl status docker //查看docker状态
systemctl enable docker //设置docker开机启动
  1. Configure Alibaba Cloud image registry (image acceleration)
  • Go to the Alibaba Cloud Image Accelerator interface
  • Follow the operation guide to configure
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://0o9w7e5n.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
  • Reload after configuration
systemctl daemon-reload //重新加载服务配置文件
systemctl restart docker //重启Docker服务
  1. Run Nginx via Docker
  • Get the latest Nginx image
docker search nginx //查看Nginx可用版本
docker pull nginx:latest //拉取镜像
docker images //查看本地镜像
  • Run Nginx
docker run --name nginx-test -p 8080:80 -d nginx

Access port 8080 to see the Nginx home page, running normally.

2. Install code-server#

  1. Install code-server
curl -fOL https://github.com/cdr/code-server/releases/download/v4.4.0/code-server-4.4.0-amd64.rpm
sudo rpm -i code-server-4.4.0-amd64.rpm
sudo systemctl enable --now code-server@dreaife
  1. Configure code-server
sudo systemctl enable --now code-server@dreaife //启动coder-server服务
sudo vi ~/.config/code-server/config.yaml //修改配置文件
sudo systemctl restart code-sercer@dreaife //重启code-server
  1. Deploy code-server to listen on 0.0.0.0
sudo vi ~/.config/code-server/config.yaml //修改配置文件
sudo systemctl restart code-sercer@dreaife //重启code-server
firewall-cmd --zone=public --add-port=7777/tcp --permanent //开放端口

After installation, enter the code-server interface

3. Configure the code-server build environment#

  1. Install the C/C++ components of code-server via VSIX
  2. Enable .vscode configuration files
  • c_cpp_properties.json

iWM4JDYnke5twCm.png

  • launch.json

DeKW5BM21nfzgsx.png

  • tasks.json

Uh2TIQKx6VwzBnp.png

  1. Test installation results
  • Create a test file test.cpp
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
int n,a[N];
string s;
void solve(){
cout<<"hello"<<endl;
}
int main(){
int _;cin>>_;
while(_--) solve();
return 0;
}
  • Run the test

MaGmNUobEurdwOc.png

The run is successful, the result is correct, and the online compiler configuration is complete.

Share

If this article helped you, please share it with others!

Configure Docker + code-server on Alibaba Cloud to Build an Online Compiler
https://dreaife.tokyo/en/posts/alicloud-docker-coder/
Author
dreaife
Published at
2022-07-06
License
CC BY-NC-SA 4.0

Some information may be outdated

Related Posts Smart
1
Experiment 8: Deployment and Application of a Web Server
cs-base This experiment aims to understand the structure of email systems, client-server communication, and SMTP/POP3 protocols. By installing and deploying Nginx and Apache on Alibaba Cloud, it demonstrates access to static and dynamic web pages, resolves dependency package installation issues, and improves understanding of Linux software configuration and programming ability.
2
Experiment 2: IP Protocol Analysis
cs-base This experiment aims to understand the IP packet format and the meaning of its fields, and to master the use of tcpdump and Wireshark. The environment includes an Alibaba Cloud host and operating systems. Through packet capture with tcpdump and analysis with Wireshark, it studies the IP protocol structure and related commands, resolves traceroute and Xftp connection issues, and improves programming ability and understanding of IP.
3
Experiment 5: Email
cs-base This experiment aims to understand the basic structure of email systems and communication protocols including SMTP and POP3. By sending and receiving emails using mail agents, clients, webmail, and telnet commands, the communication process and protocols are analyzed. The results show a clearer understanding of the detailed mail sending workflow and SMTP protocol analysis, improving programming ability and protocol understanding.
4
Experiment 7: HTTP Protocol Analysis and Measurement
cs-base This experiment aims to understand the HTTP protocol and its message structure, and to master HTTP packet capture and analysis using tcpdump and Wireshark. By downloading the Xinjiang University homepage, it analyzes the HTTP version, IP addresses, status code, content length, and header fields. A connection error encountered during the experiment was resolved, improving programming skills and understanding of HTTP.
5
Experiment 4: TCP Protocol Analysis
cs-base This experiment aims to understand the basic concepts of the TCP protocol and packet structure, analyze connection establishment and teardown, and master TCP protocol analysis using tcpdump and Wireshark. The experiment downloads a web page with wget and captures packets, analyzes TCP headers and fields, explores the three-way handshake and four-way termination processes, and summarizes issues and solutions encountered, improving understanding of IP protocols and TCP packet structure.

Table of Contents