Work memo when building a simple execution environment of C language with Docker. Built in Ubuntu 16.04 environment.
--Folder structure
- clang_test
- Dockerfile
- main.c
--Create a Dockerfile
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y sudo
RUN sudo apt-get install -y \
build-essential \
vim
--Create main.c
main.c
#include <stdio.h>
int main()
{
puts("Hello World.");
return 0;
}
--Launch Docker container
$ cd clang_test
$ docker build -t ubuntu/clang:16.04 .
$ docker run -it -d -v {clang_absolute path of test}:/home --name clang {Image ID} bash
$ docker exec -it clang bash
--Compile main.c
#Run inside a clang container
$ cd /home
$ cc -o main main.c
$ ./main
Hello World.
Recommended Posts