I have an image that I want to run on my local machine. I took this image from my friend and not from docker-hub or any repository. The file shared is in ".img" format.
I am able to import this image on docker but unable to run.
What I did:
Compress the image file from ".img" format to ".tar.gz" format so that the docker image can be imported. I used 7-zip tool to convert this.
From my local I imported the docker image using this new file(.tar.gz)<
Trying to run this imported image but fails.
Commands Executed:
PS C:\Users\C61464> docker import .\Desktop\regchange.tar.gz
sha256:a0008215897dd1a7db205c191edd0892f484d230d8925fd09e79d8878afa2743
PS C:\Users\C61464> docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
<none> <none> 7fdbbdcc59c4 2 minutes ago 1.05GB
PS C:\Users\C61464> docker tag 7fdbbdcc59c4 bwise:version1.0
PS C:\Users\C61464> docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
bwise version1.0 7fdbbdcc59c4 3 minutes ago 1.05GB
PS C:\Users\C61464> docker run -p 8888:80 bwise:version1.0
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: No command specified.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
I searched a lot for this error and found that for running we need to specify the path used while creating the image(In Dockerfile) but I am not sure as I am new to docker. Am I doing something wrong or I need to have the docker file to run this image?
Perhaps the Docker Image you have had no CMD or ENTRYPOINT defined when it was built, so the docker daemon doesn't know what to do with the image
Try doing
docker run -it -p 8888:80 bwise:version1.0 sh
(if it's a *nix based image). That should start an interactive shell.
You can do:
docker run -p 8888:80 bwise:version1.0 {command_you_want_to_run}
On the image when starting it.
The docker image may be broken.
Look inside. See suggestions how to in How to see docker image contents
Run this command to inspect your image
docker inspect [docker-image-name]
Inspect you will see base image and other info about that image
Related
I created a docker image using a script. The docker image got created successfully but when I am trying to run on the browser, I get the following message
I tried to resolve the error using webapps but it is popping up the same message.
It is happening probably because the directory /usr/local/tomcat/webapps is empty. as you can see in the description in the Docker Hub official image:
You can then go to http://localhost:8888 or http://host-ip:8888 in a browser (noting that it will return a 404 since there are no webapps loaded by default).
To solve that, you can just create a new image and copy and paste what you want inside of the folder /usr/local/tomcat/webapps.
For example, you can find inside of the folder /usr/local/tomcat/webapps.dist files of the tomcat webapp manager. If you try to see what is that you can run:
$ docker run -it tomcat:10 ls /usr/local/tomcat/webapps.dist
ROOT docs examples host-manager manager
Now that you know what is inside of the folder /usr/local/tomcat/webapps.dist, create your own Dockerfile and copy and paste this folder to /usr/local/tomcat/webapps:
FROM tomcat
RUN cp -R /usr/local/tomcat/webapps.dist/* /usr/local/tomcat/webapps
CMD ["catalina.sh", "run"]
Build the image:
$ docker build . -t custom-tomcat
Execute the image:
$ docker run -d -P custom-tomcat
Check the port opened:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
58390eab3fec custom-tomcat "catalina.sh run" 9 minutes ago Up 9 minutes 0.0.0.0:49163->8080/tcp, :::49163->8080/tcp lucid_joliot
Open your browser and check if it works:
I use docker-compose for local development on my Mac. I have multiple images being built with docker compose. My docker and docker-compose set up is very standard. Now I want to share my locally built image file with someone. Where are these local files stored?
Searching a bit gave me answers like:
~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
But then how can I extract one image from this and share? I tried running the tty that is present with it, but to no avail.
Docker Version: 18.03 Docker for Mac
Docker compose Version: 2
If you have docker-hub account (which is free), then you can use docker push command to save docker image into registry and use docker pull to pull on other machine.
Another solution is to use save + import commands.
For that you can use docker save and docker import commands.
docker#default:~$ docker save --help
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o, --output string Write to a file, instead of STDOUT
docker#default:~$
After that you have TAR file on your file system (check -o value) then transfer the file to another machine and execute docker import
docker#default:~$ docker import --help
Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Import the contents from a tarball to create a filesystem image
Options:
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Set commit message for imported image
docker#default:~$
Apparently, the solution with docker-compose is using the docker save command. We do not need to know the locations of images as #fly2matrix mentioned. We can use the docker save command to save the image in TAR file.
docker save --output image-name.tar image-name:tag
Then this image can be shared and loaded by other users through:
docker load --input image-name.tar
I have installed docker in a system which has no connection to Internet so to run an image with docker, I had to download a simple image from this and from another system. Then I put this image in my offline system in this path : C:\Users\Public\Documents\Hyper-V\Virtual hard disks
but when I run docker run hello-world in cmd I see this message:
Unable to find image 'hello-world:latest' locally
and tries to download hello-world image form Internet but it has to no connection to the Internet so it field. Now I want to know where I should put my images in to be visible to docker?
You can do it the easy way without messing around with folders, by exporting the docker image from any other machine with access to internet:
pull the image on a machine with internet access.
$docker pull hello-world
save that image to a .tar file.
$ docker save --output hello-world.tar {your image name or ID}
copy that file to any machine.
load the .tar file to docker.
$docker load --input hello-world.tar
Check out:
https://docs.docker.com/engine/reference/commandline/image_save/
https://docs.docker.com/engine/reference/commandline/load/#examples
You are trying to start a container using the dockerfile. You need to first build the image from dockerfile. You can do this via
docker build -t < image name > < path >
You will require the internet connection while building the image.
You can check the image in your system using
docker images
Once you build the docker image you can start the container without internet connection using
docker run < image name >
Also you can export the same image using docker save and docker load functionalities.
Docker runs in a client-server architecture environment just almost like git. It can pull resources from the server online with the client on "your machine".
The command $docker pull hello-world requires connection to the server as part of docker itself.
I have installed Docker for Windows. I have downloaded HDP_2.5_docker.tar from http://hortonworks.com/downloads/#sandbox which is a 10 GB file.
How can I load an image tar file? I have tried this command:
docker import HDP_2.5_docker.tar
You can use docker load
Usage: docker load [OPTIONS]
Load an image from a tar archive or STDIN
Git bash console:
docker load < HDP_2.5_docker.tar
Windows cmd:
docker load -i windowsservercore.tar
Firstly, put the tar file under your user folder: i.e: C:\Users\yourName\xxx.tar
Secondly, run the Docker load CMD:
docker load -i xxx.tar
After it is done, we could see the file is loaded as Docker images by running CMD:
docker images
you can do:
docker image import file.tar images_name:image_tag
Load the desired docker file, assuming you are in the same directory as the tar file, you can use -
$ docker load -i filename.tar
On successful import, you will see a success message along with the image ID
Check in the docker images for the image ID that you just received:
docker images
You will see the docker loaded successfully in the docker images list. However, there is one thing worth mentioning in case you might get confused; the date reflected in the command output might reflect the date when docker is created. Assuming, docker got created 5 days ago then the same will be shown in the output. Better way to confirm if your docker is loaded or not is to check for the image ID or repo and tag name (if you know).
You can finally run the docker using the command -
$ docker run -it image-ID
I'm new to Docker, so please allow me to describe the steps that I did. I'm using Docker (not Docker toolbox) on OS X. I built the image from Dockerfile using the following command
sudo docker build -t myImage .
Docker confirmed that building was successful.
Successfully built 7240e.....
However, I can't find the image anywhere. I looked at this question, but the answer is for Docker toolbox, and I don't have a folder /Users/<username>/.docker as suggested by the accepted answer.
You would be able to see your docker images by the below command:
docker images
And to check which all containers are running in docker:
docker ps -a
Local builds (in my case using buildkit) will create and cache the image layers but simply leave them in the cache rather than tell the docker daemon they're an actual image. To do that you need to use the --load flag.
$ docker buildx build -t myImage .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Doesn't show anything, but...
$ docker buildx build -t myImage --load .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myImage latest 538021e3d342 18 minutes ago 190MB
And there it is!
There actually is a warning about this in the output of the build command... but it's above all the build step logs so vanishes off your terminal without easily being seen.
To get list of Images
docker image ls
or
docker images
In addition to the correct responses above that discuss how to access your container or container image, if you want to know how the image is written to disk...
Docker uses a Copy on Write File System (https://en.wikipedia.org/wiki/Copy-on-write) and stores each Docker image as a series of read only layers and stores them in a list. The link below does a good job explaining how the image layers are actually stored on disk.
https://docs.docker.com/storage/storagedriver/
As already said, after the docker images
this command will show you all the images you have locally.
i.e "somth like that"
REPOSITORY TAG IMAGE ID CREATED SIZE
codestandars 1.0 a22daacf6761 8 minutes ago 622MB
bulletinboard 1.0 b73e8e68edc0 2 hours ago 681MB
ubuntu 18.04 cf0f3ca922e0 4 days ago 64.2MB
now you should
docker run -it and the IMAGE ID or the TAG related to the repository you want to run.
Command to list the docker images is :
docker images
The default docker images will show all top level images, their repository and tags, and their size.
An image will be listed more than once if it has multiple repository names or tags.
Click here for the screenshot for more details