skip to Main Content

This is my command:

docker run -d --name di MY_DOCKER_IMAGE/cli start accept --token your_token_here

I want to run the contaniner with my image and this parameters from Dockerfile.

Example:

FROM my_docker_image:latest

CMD -d --name di MY_DOCKER_IMAGE/cli start accept --token your_token_here

Something like this that when runs the container image runs with the specified parameters and not just pull the image.

Thanks

2

Answers


  1. The CMD command is just to run one command INSIDE the container. If you want to run something like you descripted in your post you should take a look at docker-compose like @Jeffrey Mixon mentioned.

    Login or Signup to reply.
  2. With docker compose, you can run your container with those parameters by doing

    docker compose up -d
    

    Create a file called docker-compose.yml and put this inside it

    version: '3'
    
    services:
      di:
        image: MY_DOCKER_IMAGE/cli
        container_name: di
        command: start accept --token your_token_here
    

    Then, when you do docker compose up -d, your container will be started with the same parameters as in your docker run command.

    Depending on your version of docker compose, you might have to use docker-compose up -d (with a dash in ‘docker-compose’).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search