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
Forwarding Network Traffic to a Router via NAT on Ubuntu
cs-base Configure Netplan, enable IP forwarding, and set up NAT to allow Ubuntu to share its network connection with a router. The process includes clearing existing configurations, assigning a static IP address, installing and configuring a DHCP service, and verifying that network sharing works correctly.
2
Installing Oh My Zsh and Its Plugins on Ubuntu
cs-base To install Oh My Zsh and its components on Ubuntu, first install Zsh and Git, then install Oh My Zsh using wget. Next, clone the Powerlevel10k theme and required plugins, and update the .zshrc file to enable them. Finally, install additional plugins such as zsh-bat and you-should-use, and update the system to ensure everything works properly.
3
About Errors When Using pandas.to_datetime with Different Time Formats
cs-base When using the pandas to_datetime function, errors may occur if date values use different formats. Setting the format parameter to 'mixed' can solve issues caused by inconsistent formats. Example code shows how to handle invalid date formats and successfully convert values to datetime.
4
CSAPP Chapter 1: A Tour of Computer Systems
cs-base A computer system consists of hardware and system software and runs applications through a program life cycle of creation, execution, output, and termination. Information is made of bits and context, and programs are transformed into executables by the compilation system. The processor reads and executes instructions, using caches to improve performance. The operating system manages hardware and provides abstractions such as processes and virtual memory to support concurrency and parallelism. Abstraction is a core concept in computer science, and virtual machines provide an abstraction of an entire computer.
5
missing-semester-class01
cs-base Introduces the basic features and usage of the shell, including running programs, navigating paths, managing file permissions, redirecting input and output streams, and administering root privileges. It also provides multiple Bash command examples and exercises to reinforce the material.

Table of Contents