Reputation: 1649
Having that question coming into my mind where I wanted to know how docker behaves in these different scenarios.
docker-compose
version: '3.8'
services:
x:
image: x
y:
image: y
docker command
docker run x
docker run y
Upvotes: 0
Views: 372
Reputation: 15568
One of the main different is you can't create resources (eg. network, volume) with docker run
, you need to pre-create such resources before use (imperative). You can declare resources in the compose file and docker will create for you, including removal with down
command. Compose works on group of services while the formal works on one at a time. Compose file can also used for docker stack
, attributes not compatible with stack will be ignore automatically; where docker run
has no support to Swarm mode.
Upvotes: 1