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.
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
https://github.com/kyorohiro/clang-code-server
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
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
https://code.visualstudio.com/docs/languages/cpp
(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
root@59757234cc79:/works/w# g++ hello.cpp
root@59757234cc79:/works/w# ./a.out
Hello, World!!root@59757234cc79:/works/w#
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