0

Is it possible to RUN a command within docker-compose.yml file? So instead of having a dockerfile where I have something like this RUN mkdir foo, to have the same command withing the docker-compose.yml file

services:
    server:
        container_name: nginx
        image: nginx:stable-alpine
        volumes:
            - ./public:/var/www/html/public
        ports:
            - "${PORT:-80}:80"
        ???: 'mkdir foo' // <--- sudo code
ltdev
  • 3,461
  • 17
  • 60
  • 117
  • 1
    No, there's no way to do this, only to override the single command that is the main container process. (Also see [Using Docker-Compose, how to execute multiple commands](https://stackoverflow.com/questions/30063907/using-docker-compose-how-to-execute-multiple-commands).) Why do you want to do this, rather than building a self-contained ready-to-run Docker image? – David Maze May 26 '22 at 16:02

0 Answers0