olange / arcade

A distributed arcade game and mashup of a few delighful arcade games from the eighties — including restoration of an original Pacman Arcade Cocktail table (Karateco 1984)
https://d-arcade.app
Apache License 2.0
1 stars 1 forks source link

Script to remove running Docker container #1

Closed rudifa closed 4 years ago

rudifa commented 4 years ago

@olange Is there a better way to handle this problem: npm run server fails if the container name is already in use

My problem:

engine % npm run server
...
docker: Error response from daemon: Conflict. The container name "/arcade-engine" is already in use by container ... 
You have to remove (or rename) that container to be able to reuse that name.

My solution:

+    "server": "docker run --detach --name arcade-engine --publish 4000:4000 olange/arcade-engine",
+    "kill": "docker rm -f $(docker ps -a --filter 'name=arcade-engine' -q)"

Is there a better way to handle this situation?

olange commented 4 years ago

The scripts are now named more consistently; see package.json:

  …
  "scripts": {
    "start": "node index.js",
    "test":  "echo \"Error: no test specified\" && exit 1",
    "docker:build": "DOCKER_BUILDKIT=1 docker build --tag olange/arcade-engine .",
    "docker:start": "docker run --detach --name arcade-engine --publish 4000:4000 olange/arcade-engine",
    "docker:stop":  "docker rm -f $(docker ps -a --filter 'name=arcade-engine' -q)"
  },
  …