Home > other >  docker exit after executing the command?
docker exit after executing the command?

Time:02-23

I need to compile gem5 with the environment inside docker. This is not frequent, and once the compilation is done, I don't need the docker environment anymore. I have a docker image named gerrie/gem5. I want to perform the following process.

Use this image to create a container, mount the local gem5 source code, compile and generate an executable file(Executables are by default in the build directory.), exit the container and delete it. And I want to be able to see the compilation process so that if the code goes wrong, I can fix it.

But I ran into some problems.

  1. docker run -it --rm -v ${HOST_GEM5}:${DOCKER_GEM5} gerrie/gem5 bash -c "scons build/X86/gem5.opt"

When I execute the above command, I will go to the docker terminal. Then the command to compile gem5(scons build/X86/gem5.opt) is not executed. I think it might be because of the -it option. When I remove this option, I don't see any output anymore.

I replaced the command with the following sentence.

  1. docker run -it --rm -v ${HOST_GEM5}:${DOCKER_GEM5} gerrie/gem5 bash -c "echo 'hello'" But I still don't see any output.

  2. When I went into the docker container and tried to compile it myself, the build directory was generated. I found that outside docker, I can't delete it.

What should I do? Thanks!

dockerfile

FROM matthewfeickert/docker-python3-ubuntu:latest
LABEL maintainer="Yujie  [email protected]"
USER root
# get dependencies

RUN set -x; \
        sudo  apt-get update \
        && DEBIAN_FRONTEND=noninteractive sudo  apt-get install -y  build-essential git-core m4 zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev swig  \
        && sudo -H python  -m pip install scons==3.0.1 \
        && sudo -H python  -m pip install six

RUN apt-get clean

# checkout repo with mercurial
# WORKDIR /usr/local/src
# RUN git clone https://github.com/gem5/gem5.git

# build it
WORKDIR /usr/local/src/gem5

ENTRYPOINT bash

I found that when downloading gem5, it may be because gem5 is too big, and it keeps showing "fatal: unable to access 'https://github.com/gem5/gem5.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated." mistake

So I commented out the RUN git clone https://github.com/gem5/gem5.git command

CodePudding user response:

You could make the entrypoint scons itself.

ENTRYPOINT ["scons"]

Or absolute path to the bin. I don't know where it will be installed to, you need to check.

ENTRYPOINT ["/usr/local/bin/scons"]

Then you can run

docker run -it --rm -v ${HOST_GEM5}:${DOCKER_GEM5} gerrie/gem5 build/X86/gem5.opt

If the sole purpose of the image is to invoke scons, it would be kind of idiomatic.

Otherwise, remove the entrypoint. Also note, you don't need to wrap it in bash -c

If you have removed the entrypoint you can run it like this.

docker run -it --rm -v ${HOST_GEM5}:${DOCKER_GEM5} gerrie/gem5 scons build/X86/gem5.opt
  • Related