Emulating Linux binaries under Mac OS X

前端 未结 6 1298
Happy的楠姐
Happy的楠姐 2021-02-01 16:11

How do I run Linux binaries under Mac OS X?

Googling around I found a couple of emulators but none for running Linux binaries on a Mac. There are quite a few posts about

6条回答
  •  广开言路
    2021-02-01 17:11

    noah does not allow the binaries to execute properly for me. Use Docker Desktop for Mac.

    Just do: docker pull centos:latest # 73MB CentOS docker image

    Make a folder for what is needed to run your binary, and in your Dockerfile:

    FROM centos
    COPY your_binary /bin/
    ENTRYPOINT ["your_binary"]
    

    and you can build it with

    docker build -t image_name

    then execute with

    docker run image_name as if it were the binary itself. Worked for me. Hope it helps someone else. And if you need specific outputs or to store files somewhere you can mount volumes onto the docker with -v, for example:

    docker run -v path_to_my_stuff:/docker_stuff image_name,

    though adding a WORKDIR /docker_stuff line to the Dockerfile before ENTRYPOINT is probably best.

    If you change ENTRYPOINT to

    ENTRYPOINT ["bash", "-c"] and add

    CMD ["your_binary"]

    underneath it, you can actually pass the command into the image like

    docker run -v path_on_local:/in_container_path image_name "your_binary some_parameters -optionrequiringzerowhitespacebeforeinputvalue"
    

提交回复
热议问题