Java memory allocation error inside a Docker container when host machine is running Alpine Linux

3

I want to run Jenkins in a Container where my host machine is running Alpine Linux.

I have an Ansible playbook that starts the Jenkins container. However, the container exits as soon as it starts. I believe the problem is related to starting the container on my host machine running Alpine Linux.

- name: pull jenkins image
  docker_image:
    name: jenkins/jenkins
    tag: lts-alpine

- name: create jenkins container
  docker_container:
    name: jenkins
    image: "jenkins/jenkins:lts-alpine"
    state: started
    env:
      JAVA_OPTS: "-Xmx300m"
    memory: 500M
    kernel_memory: 500M
    ports:
      - 8080:8080
      - 50000:50000
    volumes:
      - jenkins:/var/jenkins_home:rw

When I run docker ps -a I can see that the docker container exited.

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS                      PORTS                    NAMES
523f107cb861        jenkins/jenkins:lts-alpine   "/sbin/tini -- /usr/…"   28 seconds ago      Exited (1) 27 seconds ago                            jenkins

I look at the logs with docker logs jenkins to see java failed to allocate memory:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x000076cd5dda8000, 2555904, 1) failed; error='Operation not permitted' (errno=1)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2555904 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid7.log

I've tried to set the memory but I think it is related to me running the docker container in Alpine Linux. The container starts locally on OSX. My Host machine has 15G free of the available 16G.

Is there a Java option that I am missing or some thing missing from my playbook?

Tom

Posted 2018-06-16T16:37:42.907

Reputation: 31

No answers