mirror of
https://github.com/jbranchaud/til
synced 2026-01-18 06:28:02 +00:00
Compare commits
4 Commits
7cc6b648bd
...
6d33ed92a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d33ed92a5 | ||
|
|
fe9b62a631 | ||
|
|
5615da920f | ||
|
|
c60c63f554 |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1589 TILs and counting..._
|
||||
_1590 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||
@@ -195,7 +195,7 @@ See some of the other learning resources I work on:
|
||||
- [Aliasing An Ansible Host](devops/aliasing-an-ansible-host.md)
|
||||
- [Allow Cross-Origin Requests To Include Cookies](devops/allow-cross-origin-requests-to-include-cookies.md)
|
||||
- [Allow HTTPS Through Your UFW Firewall](devops/allow-https-through-your-ufw-firewall.md)
|
||||
- [Check For Cached Site Assocation File For iOS](devops/check-for-cached-site-association-file-for-ios.md)
|
||||
- [Check For Cached Site Association File For iOS](devops/check-for-cached-site-association-file-for-ios.md)
|
||||
- [Check The Status of All Services](devops/check-the-status-of-all-services.md)
|
||||
- [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md)
|
||||
- [Connect To An RDS PostgreSQL Database](devops/connect-to-an-rds-postgresql-database.md)
|
||||
@@ -216,6 +216,7 @@ See some of the other learning resources I work on:
|
||||
|
||||
- [Configure Different Host And Container Ports](docker/configure-different-host-and-container-ports.md)
|
||||
- [List Running Docker Containers](docker/list-running-docker-containers.md)
|
||||
- [Prevent Containers From Running On Startup](docker/prevent-containers-from-running-on-startup.md)
|
||||
- [Run A Basic PostgreSQL Server In Docker](docker/run-a-basic-postgresql-server-in-docker.md)
|
||||
|
||||
### Drizzle
|
||||
@@ -770,7 +771,7 @@ See some of the other learning resources I work on:
|
||||
- [Check If Clusters Are Upgrade Compatible](postgres/check-if-clusters-are-upgrade-compatible.md)
|
||||
- [Check If The Local Server Is Running](postgres/check-if-the-local-server-is-running.md)
|
||||
- [Check If User Role Exists For Database](postgres/check-if-user-role-exists-for-database.md)
|
||||
- [Check Table For Any Oprhaned Records](postgres/check-table-for-any-orphaned-records.md)
|
||||
- [Check Table For Any Orphaned Records](postgres/check-table-for-any-orphaned-records.md)
|
||||
- [Checking Inequality](postgres/checking-inequality.md)
|
||||
- [Checking The Type Of A Value](postgres/checking-the-type-of-a-value.md)
|
||||
- [Clear The Screen In psql](postgres/clear-the-screen-in-psql.md)
|
||||
|
||||
53
docker/prevent-containers-from-running-on-startup.md
Normal file
53
docker/prevent-containers-from-running-on-startup.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Prevent Containers From Running On Startup
|
||||
|
||||
I have a bunch of docker containers managed by Docker Desktop. Some are related
|
||||
to projects I'm actively working on. Whereas many others are inactive projects.
|
||||
|
||||
When I restart my machine, regardless of which containers I had running or
|
||||
turned off, several of them are booted into a running state on startup. This is
|
||||
becaue their restart policy is set to `always`. That's fine for the project I'm
|
||||
actively working on, but the others I would like to be _off_ by default.
|
||||
|
||||
I need to update each of their restart policies from `always` to `no`.
|
||||
|
||||
First, I need to figure out their container IDs:
|
||||
|
||||
```bash
|
||||
$ docker ps --all
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
eb7b40aeba2d postgres:latest "docker-entrypoint.s…" 3 months ago Up 11 minutes 0.0.0.0:9875->5432/tcp still-postgres-1
|
||||
eb9ab2213f2b postgres:latest "docker-entrypoint.s…" 3 months ago Exited (0) 11 minutes ago next-drizzle-migration-repro-app-postgres-1
|
||||
ba792e185734 postgres:latest "docker-entrypoint.s…" 4 months ago Up 11 minutes 0.0.0.0:9876->5432/tcp better_reads-postgres-1
|
||||
3139f9beae76 postgres:latest "docker-entrypoint.s…" 9 months ago Exited (128) 7 months ago basic-next-prisma-postgres-1
|
||||
```
|
||||
|
||||
Referencing the `CONTAINER ID` and `NAMES` columns, I'm able to then inspect
|
||||
each container and see the current `RestartPolicy`:
|
||||
|
||||
```bash
|
||||
$ docker inspect eb9ab2213f2b | grep -A3 RestartPolicy
|
||||
"RestartPolicy": {
|
||||
"Name": "always",
|
||||
"MaximumRetryCount": 0
|
||||
},
|
||||
```
|
||||
|
||||
I can then update the `RestartPolicy` to be `no`:
|
||||
|
||||
```bash
|
||||
$ docker update --restart no eb9ab2213f2b
|
||||
```
|
||||
|
||||
Inpsecting that container again, I can see the updated policy:
|
||||
|
||||
```bash
|
||||
$ docker inspect eb9ab2213f2b | grep -A3 RestartPolicy
|
||||
"RestartPolicy": {
|
||||
"Name": "no",
|
||||
"MaximumRetryCount": 0
|
||||
},
|
||||
```
|
||||
|
||||
Rinse and repeat for each of the offending containers.
|
||||
|
||||
[source](https://stackoverflow.com/questions/45423334/stopping-docker-containers-from-being-there-on-startup)
|
||||
Reference in New Issue
Block a user