Search code examples
dockeropenalpr

Cannot Start OpenALPR Docker Container


I've seen a post similar to mine but mine's a bit different. I feel I maybe doing something wrong.

I've created this Dockerfile in a folder. Then in that folder:

docker build -t openalpr https://github.com/openalpr/openalpr.git

All went well: docker images.

Create a container:

docker create --name foocontainer <IMAGE>

Now, docker container ls -a I see my container. I need to ssh into it so I need to start before attach? docker start <container id> No message after that so I then docker ps I see nothing. I need to docker attach <container id> so I can run bash commands. Any help? Im on a Mac.


Solution

  • I have done the following which might help you debug and understand Docker better.

    1. Use CMD instead of ENTRYPOINT. The basic reason is to be able to override CMD when you run a new container. Read more about this practice here: What is the difference between CMD and ENTRYPOINT in a Dockerfile?. So, I have changed your Dockerfile a bit...

      entrypoint ["/bin/sh","-c"]
      cmd ["alpr"]
      
    2. Build your image again

      docker build -t openalpr .
      
    3. Run a new container like this:

      docker container run -itd --rm --name=foocontainer openalpr bash
      

      Explained: --rm container will be removed after exit, bash overrides the CMD provided in your Dockerfile. A container is up as long as this CMD runs. At your case, alpr failed and the container exited. Now it will stay up.

    4. If a container is up, you can "get inside" to type commands like this:

      docker container exec -it foocontainer bash
      

    From this point now, you will be able to run alpr and see why it fails without the container being stopped.

    I hope I've shed some light... :-)