Hello World with Docker and C

Overview

Work memo when building a simple execution environment of C language with Docker. Built in Ubuntu 16.04 environment.

Contents

--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

Hello World with Docker and C
Hello world with Kotlin and JavaFX
Hello World with GWT 2.8.2 and Maven
Hello world with Kotlin and Tornado FX
Hello World with Micronaut
Run JSP Hello World with Tomcat on Docker
Easy to display hello world with Rails + Docker
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with VS Code!
Hello World with Spring Boot
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
(Intellij) Hello World with Spring Boot
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
"Hello world" for ImageJ with Eclipse
Microservices With Docker and Cloud Performance
Encrypt with Java and decrypt with C #
Android OS (7.1.2) build and Hello World
Hello world in Java and Gradle
[Swift] Create a project with Xcode (ver 12.1) and display "Hello, World!"
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Building Rails 6 and PostgreSQL environment with Docker
Hello World with Eclipse + Spring Boot + Maven
Link Java and C ++ code with SWIG
Hello world with Java template engine Thymeleaf
Java development with Codenvy: Hello World! Run
Communicate Gitlab and Gitlab Runner launched with Docker
"Hello, World!" With Kotlin + CLI in 5 minutes
How Spring Security works with Hello World
(IntelliJ + gradle) Hello World with Spring Boot
How to run Blazor (C #) with Docker
Minimal Java environment construction and Hello World
Read "Hello world"
Try writing "Hello, World" with a combination of various languages and libraries
Java, Hello, world!
Java Hello World
Experience .NET 5 with Docker and Visual Studio Code
Docker + DynamoDB local + C ++ environment construction and practice
Hello World with JavaFX 11 (OpenJFX) in Liberica JDK 11
Hello world! With Spring Boot (Marven + text editor)
Build Java environment and output hello world [Beginner]
I also tried WebAssembly with Nim and C
Create jupyter notebook with Docker and run ruby
Until you install Gradle and output "Hello World"
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Prepare a scraping environment with Docker and Java
Show a simple Hello World with SpringBoot + IntelliJ
Try to display hello world with spring + gradle
Hello World with Java Servlet and JSP (Easy web server startup with Maven + Jetty)
CI/CD pipeline and Docker
"Hello World" in Java
Hello World (REST API) with Apache Camel + Spring Boot 2
Solving with Ruby, Perl and Java AtCoder ABC 128 C
Docker installation and initialization
Docker terms and commands
Launch MariaDB with Docker
Rails deploy with Docker
Java Learning (1)-Hello World
Run Pico with docker