Build Clang x VSCode on Docker (1)

It is easy to prepare the C / C ++ development environment with Docker. In this article, I also included VS Code in Docker. Since the entire development environment can be managed with Docker, it is recommended because it is easy to manage.

It is good that there is no difference when creating an environment for server side or learning.

Character

What is Docker

It is an environment to run an application in a container on Linux. Applications and libraries can be consolidated in the same container and reused. https://ja.wikipedia.org/wiki/Docker

VSCode https://ja.wikipedia.org/wiki/Visual_Studio_Code It is an Editor made by Microsoft. If you install Dart Plugin, you can use the interpolation function etc. and it is convenient.

Code-Server It's a great guy who can run VS Code as a web service. https://github.com/cdr/code-server

Try to create an environment

https://github.com/kyorohiro/clang-code-server

(1) Write a dockerfile

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y curl wget gnupg less lsof net-tools git apt-utils -y

# WORKDIR
RUN mkdir /works
WORKDIR /works

# C
RUN apt-get install build-essential -y
RUN apt-get install libboost-all-dev -y

#
# CODE-SERVER
RUN wget https://github.com/cdr/code-server/releases/download/1.939-vsc1.33.1/code-server1.939-vsc1.33.1-linux-x64.tar.gz
RUN tar xzf code-server1.939-vsc1.33.1-linux-x64.tar.gz -C ./ --strip-components 1



(2) Run docker image

docker build -t clang_vscode .
docker run -p 8443:8443 -p 8080:8080 -it clang_vscode bash

#In docker
mkdir /works/w
/works/code-server /works/w --allow-http --no-auth

(3) and open'http://127.0.0.1:8443/' in your browser

root_page.jpg

Install c / c ++ plugin

https://code.visualstudio.com/docs/languages/cpp

I will try to make something

(0) Write Code

hello.cpp


#include<stdio.h>

int main(int argc, char** argv) {
    printf("Hello, World!!");
    return 0;
}

(1) Terminal -> New Terminal on VSCODE

(2) Enter the following on Terminal

root@59757234cc79:/works/w# g++ hello.cpp
root@59757234cc79:/works/w# ./a.out 
Hello, World!!root@59757234cc79:/works/w# 

run_page.jpg

that's all.

Code-Server was very convenient. https://github.com/cdr/code-server

the end.

The code for this time is summarized below. https://github.com/kyorohiro/clang-code-server

PS

[a] If you want to resume

$ docker ps -a
check id and
$ docker start < id > 
$ docker exec -it < id > bash

[b] If you want to change the settings $ docker commit < id > clang_vscode_xxx $ docker run -p 8443:8443 -p 8080:8080 -it clang_vscode_xxx bash

[c] Mount $ docker run -p 8443:8443 -p 8080:8080 -v /Users/kyorohiro/w/dart/xxx:/works/w -it clang_vscode bash

Recommended Posts

Build Clang x VSCode on Docker (1)
Build Java x Spring x VSCode x Gradle on Docker (1)
[Vscode xdebug3.0 x PHP x Docker]
Build PlantUML environment with VSCode + Docker
Build Unity development environment on docker
Build an ASP.net Core Web API environment on Docker (VSCode) Part 1
Build an ASP.NET Core Web API environment on Docker (VSCode) Part 2
Build Redmine code reading environment on Docker
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Liberty on Docker
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
clang ++ docker upgrade
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Redmine on Docker
Introducing Rspec with Ruby on Rails x Docker
Build a container for Docker x Laravel phpMyAdmin
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
Build a development environment for Docker, java, vscode
Docker installation on CentOS 6
Easily build Redmine on Windows using WSL2 and Docker
python notes on docker
Docker x Rails 6 (memo)
Install Docker on Manjaro
[Docker] Build an Apache container on EC2 using dockerfile
Build Rails (API) x MySQL x Nuxt.js environment with Docker
M.S. docker on Windows
Build Zabbix on Ubuntu 20.04
Docker installation on WSL2
Run phpunit on Docker
[Amateur remarks] Build multiple WordPress on AWS using Docker Compose
[Docker] Build a site on Hugo and publish it on GitHub
Build a container that automatically formats Docker x Laravel code
I tried to build the environment of WSL2 + Docker + VSCode
Install Docker on Raspberry Pi
Install Docker on Windows 10 PRO
Launch a terminal on VScode
Run VS Code on Docker
Build VNC Server on Ubuntu 20.04
Install Docker on Ubuntu Server 20.04
Run openvpn on Docker (windows)
Try Docker on Windows 10 Home
Manually build OpenJDK on Windows
Ubuntu on Windows build speed
Build docker environment with WSL
Hosted Apicurio Studio on Docker
Install docker on AWS EC2
Docker Easy Build Database (PostgreSQL)
Build DynamoDB local with Docker
multi-project docker build using jib
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)