I am trying to mount a volume and although the volume gets mounted none of the files exist. I am running:
OS Version/build
20.04.6 LTS (Focal Fossa)
App version
Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1
Docker Compose version v2.0.1
Here is my docker_compose.yml file:
version: '2'
networks:
ros-network2:
external: true
volumes:
src:
services:
ros-master2:
image: ros:noetic
command: roscore
networks:
ros-network2:
ipv4_address: 172.21.1.5
ros-visualizer1:
tty: true
image: ros_noetic
container_name: jackal_v1
build:
context: .
dockerfile: Dockerfile-1
networks:
ros-network2:
ipv4_address: 172.21.1.14
volumes:
- src:/src
environment:
- ROS_MASTER_URI=http://172.21.1.5:11311
- ROS_IP=172.21.1.14
# command: python3 /src/jackal_visualizer1.py
ros-visualizer2:
tty: true
image: ros:noetic
container_name: jackal_v2
build:
context: .
networks:
ros-network2:
ipv4_address: 172.21.1.15
volumes:
- src:/src
environment:
- ROS_MASTER_URI=http://172.21.1.5:11311
- ROS_IP=172.21.1.15
command: python3 /src/jackal_visualizer2.py
ros-visualizer3:
tty: true
image: ros:noetic
container_name: jackal_v3
build:
context: .
networks:
ros-network2:
ipv4_address: 172.21.1.16
volumes:
- src:/src
environment:
- ROS_MASTER_URI=http://172.21.1.5:11311
- ROS_IP=172.21.1.16
command: python3 /src/jackal_visualizer3.py
When I comment out the command: as I did in service ros-visualizer1, and run
docker-compose exec ros-visualizer1 bash
I could see the /src directory but it is empty. When I run the services ros-visualizer2 and ros-visualizer3 with command: as shown in the docker-compose.yml file I get:
jackal_v2 | python3: can’t open file ‘/src/jackal_visualizer2.py’: [Errno 2] No such file or directory
jackal_v3 | python3: can’t open file ‘/src/jackal_visualizer3.py’: [Errno 2] No such file or directory
jackal_v3 exited with code 2
jackal_v2 exited with code 2
I am sure the files exist in my local directory:
ls src
jackal_visualizer1.py jackal_visualizer2.py jackal_visualizer3.py
I am new to docker-compose and new to the forum. Any help would be appreciated.