我想在主机运行 Alpine Linux 的容器中运行 Jenkins。
我有一个用于启动 Jenkins 容器的 Ansible 剧本。但是,容器一启动就会退出。我认为问题与在运行 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
当我运行时,docker ps -a
我可以看到docker容器退出了。
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
我查看日志docker logs jenkins
发现 java 无法分配内存:
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
我尝试设置内存,但我认为这与我在 Alpine Linux 中运行 docker 容器有关。容器在 OSX 上本地启动。我的主机有 16G 可用内存中的 15G 可用。
我是否遗漏了 Java 选项或者我的剧本中缺少了某些内容?