I'm working on a application where i am running different container such as clamav,postgres,my quarkus application.all the configuration is defined in docker compose file.now i want to perform some operation on file that's why want to use ffmpeg. i am using ffmpeg as separate container and connected via docker network.i want to execute some ffmpeg command for example check version and other advance.I'm getting error. Please help me to solve this.
My docker-compose.yml --
version: "3.8"
services:
clamav:
image: clamav/clamav:latest
container_name: clamav
ports:
- "3310:3310"
restart: always
healthcheck:
test: ["CMD", "clamdscan", "--version"]
interval: 30s
timeout: 10s
retries: 5
networks:
- techtonic-antivirus-net
postgres-database:
image: postgres:15
container_name: postgres
environment:
POSTGRES_DB: antivirustt
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5434:5432"`enter code here`
restart: always
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- techtonic-antivirus-net
# Add Redis container
redis:
image: redis:latestenter code here
container_name: redis
ports:
- "6379:6379"
restart: always
networks:
- techtonic-antivirus-net
ffmpeg:
image: jrottenberg/ffmpeg:latest
container_name: ffmpeg
restart: always
entrypoint: ["tail", "-f", "/dev/null"] # Keeps the container running
networks:
- techtonic-antivirus-net
healthcheck:
test: ["CMD", "ffmpeg", "-version"]
interval: 10s
timeout: 5s
retries: 3
techtonic-antivirus:
build:
context: .
dockerfile: src/main/docker/Dockerfile.native-micro
container_name: techtonic-antivirus
depends_on:
clamav:
condition: service_healthy
postgres-database:
condition: service_started
redis:
condition: service_started
ports:
- "8080:8080"
environment:
- CLAMAV_HOST=${CLAMAV_HOST}
- CLAMAV_PORT=${CLAMAV_PORT}
- QUARKUS_PROFILE=${QUARKUS_PROFILE:-dev}
- QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://postgres-database:5432/antivirustt
- QUARKUS_DATASOURCE_USERNAME=postgres
- QUARKUS_DATASOURCE_PASSWORD=postgres
- QUARKUS_REDIS_HOSTS=redis://redis:6379
restart: always
volumes:
- ffmpeg:/ffmpeg
- /var/run/docker.sock:/var/run/docker.sock
networks:
- techtonic-antivirus-net
volumes:
pgdata:
ffmpeg:
networks:
techtonic-antivirus-net:
My Service code :
@Slf4j
@ApplicationScoped
public class CheckFFmpegStatus {
public static boolean isFFmpegReady() {
try {
// ProcessBuilder pb = new ProcessBuilder("docker", "exec", "ffmpeg", "ffmpeg", "-version");
ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-version");
Process process = pb.start();
int exitCode = process.waitFor();
if (exitCode == 0) {
log.info("✅ FFmpeg is ready and reachable inside the container.");
} else {
log.warn("⚠️ FFmpeg process exited with code: " + exitCode);
}
return exitCode == 0;
} catch (IOException | InterruptedException e) {
log.error("❌ Failed to check FFmpeg status", e);
return false;
}
}
}
ffmpeg
directly in your image's Dockerfile.entrypoint: tail -f /dev/null
does absolutely nothing and you can delete it. You shouldn't ever need to "keep the container alive". If the image doesn't have aCMD
that's a long-running process then it might not work well in a Compose context, and you might need significantly escalated privileges to be able to call that image programmatically.)