简体   繁体   中英

docker-compose working but docker run not

I have a docker-compose with just one image. This is the docker-compose.yml definition:

services:
    myNodeApp:
        image: "1234567890.dkr.ecr.us-west-1.amazonaws.com/myNodeApp:latest"
        container_name: 'myNodeApp'
        volumes:
        - data:/root/data

But I want to move it to docker run as I am using just one container. Executing a docker run command as the following:

docker run 1234567890.dkr.ecr.us-west-1.amazonaws.com/myNodeApp:latest --name myNodeApp -v "data:/root/data"

But I get this message 1.12.4 . However, executing docker-compose up starts the application and shows the log by output.

What is the difference? What is the equivalent of docker-compose up with docker? What am I doing differently?

I think you are looking for this?

docker run -it --name myNodeApp -v "data:/root/data"
  1234567890.dkr.ecr.us-west-1.amazonaws.com/myNodeApp:latest 

Or maybe this command would help you, because it will build a local image associated with the config in your docker-compose.yml .

docker-compose build
docker images

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM