How to run a pulled image - docker
Asked Answered
E

6

44

I'm trying to run a pulled image without any success. I pulled an image from AWS using the Image URI.

when I run docker images I can see my pulled image:

REPOSITORY                                           TAG             IMAGE ID            CREATED             SIZE
alpine                                               3.9             055936d39205        3 weeks ago         5.53MB
24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools    dab-1.1.0slim   f994713b61cb        3 weeks ago         110MB
ubuntu                                               16.04           a3551444fc85        5 weeks ago         119MB
anapsix/alpine-java                                  8               745575fbfe52        3 months ago        126MB

I'm new at dockers, but from what I understand after pulling no need to build it, just run it but when I tried to run it like so: docker run 24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools I get the below message:

Unable to find image '24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools:latest' locally
docker: Error response from daemon: pull access denied for 24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools, repository does not exist or may require 'docker login'.

So I tried to build it like so: docker build -t 24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools and got the message:

"docker build" requires exactly 1 argument.
See 'docker build --help'.

What is the problem? How can I run a pulled image from AWS?

Exactitude answered 2/6, 2019 at 8:29 Comment(0)
M
37

There isnt any image with tag "latest" Try running using the tag "dab-1.1.0slim"

docker run 24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools:dab-1.1.0slim

Or else you could run the docker image using image id

docker run -i -t f994713b61cb

for more info on docker run command check out https://docs.docker.com/engine/reference/commandline/run/

Marketa answered 2/6, 2019 at 8:33 Comment(7)
Thanks! That worked. After running the image, I'm suppose to be inside the container , right? If I run docker ps I should see my running container?Exactitude
It seems to run but exits immediately form the container and not showing when I type docker ps. Any idea why?Exactitude
no idea, create a new thread with all the logs from the container.Marketa
Wait, I'm totally confused, when I pull an image from AWS for example, I don't have the dockerfile itself, right? To run the container do I need the dockerfile itself? If yes, how can I get it?Exactitude
If you've pulled the image using docker pull whatever, then using the docker images command will list the images you have downloaded. From there, you can run the image (without needing a dockerfile) via docker run REPOSITORY, docker run IMAGEID, or docker run REPOSITORY:TAG. (words in all-caps refer to the corresponding column from docker images output)Donaugh
@Exactitude Dockerfile is a text instruction of how to create an Image. That process is called Building. If you pull an Image it is already built, hence you don't get Dockerfile. Bringing a Container to live is a separate process called Running. To run a Container you need already built Image, so Dockerfile doesn't take part in that process. You can read more about that e.g. here.Sophey
It is best sumarized by this image.Sophey
L
4

You can use simple command

docker run -d -p [PORT_ON_YOUR_BROWSER]:[PORT_ON_CONTAINER] <Image ID>

docker run -d -p 8080:80 <Image ID>

Lupine answered 11/2, 2022 at 15:25 Comment(0)
W
2

Here is how I usually go through these steps:

    # download an image 
    > docker pull danielszabo99/microbin

    # list your images 
    > docker image ls
    
    REPOSITORY               TAG       IMAGE ID       CREATED        SIZE
    danielszabo99/microbin   latest    c6669d651bfe   37 hours ago   77.8MB

    
    > docker run danielszabo99/microbin

    # this image runs on port 8080 so we can also map it to a localhost 
    # port for browser access (local:remote)
    # docker run --publish 8080:8080  danielszabo99/microbin
Worcester answered 28/9, 2022 at 0:42 Comment(0)
A
0

Try to run the image by docker image id When building the image you need to add . at the end of your command as for an example docker build -t 24325.dkr.ecr.us-east-1.amazonaws.com/lm/rd/tools . and you need to have the Dockerfile (Assume you have).

Alcott answered 2/6, 2019 at 8:33 Comment(1)
I don't have it....I assumed that if I pulled it I have it. How can I get the dockerfile?Exactitude
D
0

Adding some information that hasn't been covered above for anyone else.

Checking what docker images are available with docker ls -al will add the image name to the terminal output allowing docker run name which is similar to using the image ID Sree has given in his answer. However, docker default names are human-readable and are created automatically when the container is built.

Davinadavine answered 11/2, 2022 at 15:34 Comment(0)
A
-6

If you want to run docker image which pulled from the remote repository just use the IMAGE ID instead of Image name (Repository).

docker run -i -t f994713b61cb /bin/bash
Agraffe answered 7/10, 2020 at 4:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.