Java and Docker don't like each other


Has anybody tried to create a docker with the environment?

My problem comes when I install minerl, I get the following error:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x000000076a82d000, 454598656, 0) failed; error='Cannot allocate memory' (errno=12)
    # There is insufficient memory for the Java Runtime Environment to continue.
    # Native memory allocation (mmap) failed to map 454598656 bytes for committing reserved memory.
    # An error report file with more information is saved as:
    # /tmp/pip-install-bpk6xbfz/minerl/minerl/env/Malmo/Minecraft/hs_err_pid44.log
    :decompileMc FAILED

Apparently the problem comes as a result that docker and java are not good friends, as you can read here:

I’ve tried to implement the proposed solution without success. Any idea?

The Dockerfile I am using follows…

Any help would be appreciated! Thanks.

FROM nvidia/cuda:10.0-base-ubuntu18.04

# Install some basic utilities
RUN apt-get update && apt-get install -y \
    curl \
    ca-certificates \
    sudo \
    git \
    bzip2 \
    libx11-6 \
    tmux \
    htop \
 && rm -rf /var/lib/apt/lists/*

# Create a working directory
RUN mkdir /code

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
 && chown -R user:user /code
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
USER user

# All users can use /home/user as their home directory
ENV HOME=/home/user
RUN chmod 777 /home/user

# Install Miniconda
RUN curl -so ~/ \
 && chmod +x ~/ \
 && ~/ -b -p ~/miniconda \
 && rm ~/
ENV PATH=/home/user/miniconda/bin:$PATH

# Create a Python 3.7 environment
RUN /home/user/miniconda/bin/conda install conda-build \
 && /home/user/miniconda/bin/conda create -y --name py37 python=3.7.3 \
 && /home/user/miniconda/bin/conda clean -ya
ENV CONDA_PREFIX=/home/user/miniconda/envs/$CONDA_DEFAULT_ENV

# CUDA 10.0-specific steps
RUN conda install -y -c pytorch \
    cuda100=1.0 \
    magma-cuda100=2.4.0 \
    "pytorch=1.1.0=py3.7_cuda10.0.130_cudnn7.5.1_0" \
    torchvision=0.3.0 \
 && conda clean -ya

# Install jupyter notebook

RUN pip install jupyter

# Install Minecraft needed libraries
RUN sudo apt-get update
RUN sudo apt-get install openjdk-8-jdk -y
CMD java -XX:+PrintFlagsFinal -Xmx900m -jar java-container.jar
RUN pip install --upgrade minerl

# Set the default command to bash
CMD ["/bin/bash"]

What operating system are you running docker on? It looks like you are out of memory! (I suspect that if you’re on Windows or Mac you’ll need to increase the allocated memory to the docker VM).

Thanks William, that actually worked. I increased the memory, and now don’t have anymore that error. But I have another one, and will open a new thread…

Out of curiosity what was this other error?