Sou iniciante com o Docker e preciso de ajuda para colocar duas imagens juntas.
Primeiro, eu tenho esses arquivos Dockerfile / docker-compose, para um Docker Container com ROS. Sozinho, funciona bem.
Dockerfile:
ARG FROM_IMAGE=ros:foxy
ARG OVERLAY_WS=/opt/ros/overlay_ws
# multi-stage for caching
FROM $FROM_IMAGE AS cacher
# clone overlay source
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS/src
RUN echo "\
repositories: \n\
ros2/codigo_gustavo: \n\
type: git \n\
url: https://github.com/GustavoLLima/codigo_gustavo.git \n\
version: master \n\
" > ../overlay.repos
RUN vcs import ./ < ../overlay.repos
# copy manifests for caching
WORKDIR /opt
RUN mkdir -p /tmp/opt && \
find ./ -name "package.xml" | \
xargs cp --parents -t /tmp/opt && \
find ./ -name "COLCON_IGNORE" | \
xargs cp --parents -t /tmp/opt || true
# multi-stage for building
FROM $FROM_IMAGE AS builder
# install overlay dependencies
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
COPY --from=cacher /tmp/$OVERLAY_WS/src ./src
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && rosdep install -y \
--from-paths \
src \
--rosdistro \
foxy \
&& rm -rf /var/lib/apt/lists/*
# build overlay source
COPY --from=cacher $OVERLAY_WS/src ./src
ARG OVERLAY_MIXINS="release"
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--packages-select \
codigo_gustavo \
--mixin $OVERLAY_MIXINS
# source entrypoint setup
ENV OVERLAY_WS $OVERLAY_WS
RUN sed --in-place --expression \
'$isource "$OVERLAY_WS/install/setup.bash"' \
/ros_entrypoint.sh
Docker-compose.yml:
version: '3'
services:
talker:
build: ./
command: ros2 run codigo_gustavo talker
listener:
build: ./
environment:
- "PYTHONUNBUFFERED=1"
command: ros2 run codigo_gustavo listener
deploy:
mode: replicated
replicas: 2
Depois, eu tenho outros arquivos Dockerfile / Docker-Compose para um Docker Container executando o NetLogo. Novamente, sozinho funciona bem.
Dockerfile:
FROM openjdk:8-jdk
LABEL maintainer="Allen Lee <[email protected]>"
ARG NETLOGO_HOME=/opt/netlogo
ARG NETLOGO_VERSION=6.0.4
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
NETLOGO_TARBALL=NetLogo-$NETLOGO_VERSION-64.tgz
ENV NETLOGO_URL=https://ccl.northwestern.edu/netlogo/$NETLOGO_VERSION/$NETLOGO_TARBALL
WORKDIR /opt
RUN wget $NETLOGO_URL && tar xzf $NETLOGO_TARBALL && ln -sf "NetLogo $NETLOGO_VERSION" netlogo \
&& rm -f $NETLOGO_TARBALL
Docker-compose.yml:
version: '3'
services:
modelo1:
build: ./
command: tail -f /dev/null
volumes:
- ./teste:/teste
volumes:
teste:
Agora o problema: estou tentando colocar esses dois códigos juntos, para usar apenas um arquivo Dockerfile / Docker-Compose, tornando-o mais fácil de executar. O problema é que consegui fazer os dois containers, mas quando tento rodar o NetLogo (via netlogo headless), o Container não consegue encontrar o Java (dependência do NetLogo). Verifiquei o diretório e parece que o Java não está instalado. O workspace vem com duas pastas, NetLogo e ROS.
Dockerfile:
#--------------Netlogo Instalation--------------
ARG FROM_IMAGE=ros:foxy
ARG OVERLAY_WS=/opt/ros/overlay_ws
#FROM openjdk:8-jdk AS netlogo_cache
FROM openjdk:8-jdk
LABEL maintainer="Allen Lee <[email protected]>"
ARG NETLOGO_HOME=/opt/netlogo
ARG NETLOGO_VERSION=6.0.4
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
NETLOGO_TARBALL=NetLogo-$NETLOGO_VERSION-64.tgz
ENV NETLOGO_URL=https://ccl.northwestern.edu/netlogo/$NETLOGO_VERSION/$NETLOGO_TARBALL
WORKDIR /opt
RUN wget $NETLOGO_URL && tar xzf $NETLOGO_TARBALL && ln -sf "NetLogo $NETLOGO_VERSION" netlogo \
&& rm -f $NETLOGO_TARBALL
#--------------ROS------------------------
#ARG FROM_IMAGE=ros:foxy
#ARG OVERLAY_WS=/opt/ros/overlay_ws
# multi-stage for caching
FROM $FROM_IMAGE AS cacher
# clone overlay source
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS/src
RUN echo "\
repositories: \n\
ros2/codigo_gustavo: \n\
type: git \n\
url: https://github.com/GustavoLLima/codigo_gustavo.git \n\
version: master \n\
" > ../overlay.repos
RUN vcs import ./ < ../overlay.repos
# copy manifests for caching
WORKDIR /opt
RUN mkdir -p /tmp/opt && \
find ./ -name "package.xml" | \
xargs cp --parents -t /tmp/opt && \
find ./ -name "COLCON_IGNORE" | \
xargs cp --parents -t /tmp/opt || true
# multi-stage for building
FROM $FROM_IMAGE AS builder
# install overlay dependencies
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
COPY --from=cacher /tmp/$OVERLAY_WS/src ./src
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && rosdep install -y \
--from-paths \
src \
--rosdistro \
foxy \
&& rm -rf /var/lib/apt/lists/*
# build overlay source
COPY --from=cacher $OVERLAY_WS/src ./src
ARG OVERLAY_MIXINS="release"
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--packages-select \
codigo_gustavo \
--mixin $OVERLAY_MIXINS
# source entrypoint setup
ENV OVERLAY_WS $OVERLAY_WS
RUN sed --in-place --expression \
'$isource "$OVERLAY_WS/install/setup.bash"' \
/ros_entrypoint.sh
#COPY --from=netlogo_cache /opt/netlogo ./netlogo
COPY --from=0 /opt/netlogo ./netlogo
Docker-compose.yml:
version: '3'
services:
talker:
build: ./
command: ros2 run codigo_gustavo talker
listener:
build: ./
environment:
- "PYTHONUNBUFFERED=1"
command: ros2 run codigo_gustavo listener
deploy:
mode: replicated
replicas: 2
modelo1:
build: ./
command: tail -f /dev/null
volumes:
- ./teste:/teste
volumes:
teste:
Contexto do erro:
cd /opt/ros/overlay_ws
./netlogo/netlogo-headless.sh --model /teste/WS2.nlogo --experiment experiment1 --spreadsheet /teste/teste2.csv
JAVA_HOME undefined, using java from path. For control over exact java version, set JAVA_HOME
./netlogo/netlogo-headless.sh: line43: java: command not found
Alguma ideia? O que devo fazer? O que estou fazendo errado?
Obrigado!