Skip to main content
Bumped by Community user
Tweeted twitter.com/StackUnix/status/707164877954097152
added 1 character in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

My docker containers are build with docker-compose and I automatically start them container on my CentOS 7 system using derivatives from the documentation example::

[Unit]
Description=condb container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a condb
ExecStop=/usr/bin/docker stop -t 2 condb

[Install]
WantedBy=local.target

Everything is working fine except for the fact that every time I want to change the container, I stop the services, run docker-compose up to create the container and then start the services, I forget that up already starts the containers.

I can adapt my script around this to stop the containers after running docker-coposecompose, but starting/shutdown takes time and I wonder if there is a way to just create the container without starting it (the build command just builds, up does build-create-start according to its help)?

My docker containers are build with docker-compose and I automatically start them container on my CentOS 7 system using derivatives from the documentation example::

[Unit]
Description=condb container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a condb
ExecStop=/usr/bin/docker stop -t 2 condb

[Install]
WantedBy=local.target

Everything is working fine except for the fact that every time I want to change the container, I stop the services, run docker-compose up to create the container and then start the services, I forget that up already starts the containers.

I can adapt my script around this to stop the containers after running docker-copose, but starting/shutdown takes time and I wonder if there is a way to just create the container without starting it (the build command just builds, up does build-create-start according to its help)?

My docker containers are build with docker-compose and I automatically start them container on my CentOS 7 system using derivatives from the documentation example::

[Unit]
Description=condb container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a condb
ExecStop=/usr/bin/docker stop -t 2 condb

[Install]
WantedBy=local.target

Everything is working fine except for the fact that every time I want to change the container, I stop the services, run docker-compose up to create the container and then start the services, I forget that up already starts the containers.

I can adapt my script around this to stop the containers after running docker-compose, but starting/shutdown takes time and I wonder if there is a way to just create the container without starting it (the build command just builds, up does build-create-start according to its help)?

Source Link

docker compose create containers without starting them

My docker containers are build with docker-compose and I automatically start them container on my CentOS 7 system using derivatives from the documentation example::

[Unit]
Description=condb container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a condb
ExecStop=/usr/bin/docker stop -t 2 condb

[Install]
WantedBy=local.target

Everything is working fine except for the fact that every time I want to change the container, I stop the services, run docker-compose up to create the container and then start the services, I forget that up already starts the containers.

I can adapt my script around this to stop the containers after running docker-copose, but starting/shutdown takes time and I wonder if there is a way to just create the container without starting it (the build command just builds, up does build-create-start according to its help)?