I am trying to build a C program inside a Docker container, I just would like to create a binary file and execute it in the container. I receive no error during compilation butwhen running within my container the binary file created on Linux Alpine I get this error message:
/usr/jjj-app/bin # ./jjj-linux.out ./jjj-linux.out: line 1: syntax error: unexpected "("/usr/jjj-app/bin #
Notes: I am running make build-linux
from the host, in my case macOS.
Any ideas how to build this simple program in Linux environment using Docker? I can use Alpine or another.
main.c
#include <stdio.h>int main() { printf("Hello, World!"); return 0;}
Makefile
build-linux: docker build -t jjj-app . docker run --publish 8081:8080 jjj-app
Dockerfile
FROM alpineRUN apk updateRUN apk add build-baseCOPY . /usr/jjj-appWORKDIR /usr/jjj-appRUN gcc /usr/jjj-app/src/main.c -o /usr/jjj-app/bin/jjj-linux.out -r