1

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.

Sylar
  • 11,422
  • 25
  • 93
  • 166
  • Use `docker container exec -it foocontainer /bin/bash` – tgogos Oct 23 '17 at 09:16
  • This might also help you: [How to get into a docker container?](https://stackoverflow.com/questions/30172605/how-to-get-into-a-docker-container) – tgogos Oct 23 '17 at 09:17
  • @tgogos Thanks but it's not runnning: `Container 1f1fe68c6690062c0e4f0ec92281986c12f4da17211c8f6b41595e43fed3b47e is not running` – Sylar Oct 23 '17 at 09:17
  • try docker ps -a . what is the status of your container? – Iurii Drozdov Oct 23 '17 at 09:17
  • When the main process of a container stops, the container exits. Try to think of a container as a process, not as a VM. Probably your container starts and stops immediately. – tgogos Oct 23 '17 at 09:19
  • @IuriiDrozdov `1f1fe68c6690 openalpr "alpr" 2 days ago Exited (1) 32 minutes ago cranky_bassi` – Sylar Oct 23 '17 at 09:21
  • Can you start it again, to tell us what happens? – tgogos Oct 23 '17 at 09:22
  • Ok, this is new. I got `libdc1394 error: Failed to initialize libdc1394` after running `docker start -a 1f1fe68c6690` – Sylar Oct 23 '17 at 09:24
  • docker logs container (https://docs.docker.com/engine/reference/commandline/logs/) might help as well. – Iurii Drozdov Oct 23 '17 at 09:24

1 Answers1

0

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... :-)

tgogos
  • 23,218
  • 20
  • 96
  • 128