I'm trying to start a docker container with docker start my_container, but it is exiting immediately. It works fine on some machines, but not on others. Here's my process:
Pull an image via docker pull <repo>:latest
Create a container via docker create --name my_container <repo>:latest
Start the container via docker start my_container
When I check the running docker processes via docker ps -a, I see that the status of my_container is Exited (1) 2 seconds ago.
When I run docker logs my_container, the only output is:
standard_init_linux.go:190: exec user process caused "exec format error"
The underlying issue in my case was an architecture mismatch.
My Dockerfile was using an amd64 base image. I built an image from this dockerfile and pushed it to a remote repository. I then pulled the image onto a device with arm32v7 architecture, created a container from the image, and tried to run the container.
A docker image built from the base image below will work on amd64 - it will not work on arm32v7.
FROM amd64/ros:kinetic-ros-core-xenial
A docker image built from the base image below will work on arm32v7 - it will not work on amd64.
FROM arm32v7/ros:kinetic-ros-core-xenial
A docker image built from a Dockerfile with the base image defined as below will default to the architecture of your current machine.
FROM ros:kinetic-ros-core-xenial
Related
Last night I pushed a basic image of CentOS to Docker Hub and I'm trying to get it to work by pulling it from Docker Hub (my repository page). Specifically, I'm trying to get "secondCommit" and I ran the image so I have it in my containers. I'm running the container with docker start <container ID> and it just shows the container ID in the command prompt but doesn't start it.
Run the image using the following command -
docker run -ti <image_name>:<tag>
I'm building an app that makes api calls to run code inside docker containers
I want to run a docker container that has docker running inside it.
I want to create a docker file that pulls other docker images inside it and then waits for api calls (on port 2376) to create, run and delete containers based on the docker images that i pulled into the dockerfile
This is the dockerfile I'm trying to create right now.
FROM docker:stable
RUN docker pull python
EXPOSE 23788
CMD tail -f /dev/null
However when the RUN command is issued i get this error message:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I don't really know how to start docker inside a docker container.
The reason i need this kind of a docker file is so that i can then use kubernetes to scale this part of my application
There's a special image for this, docker:dind. See the bit about "Docker in Docker" in https://hub.docker.com/_/docker.
I am working on single node kubernetes cluster built with kubeadm. During development, create a new docker image, but the image will be deleted immediately without permission from kubernetes garbage collection. How do I control this?
Environment:
kubeadm version: v1.17.2
kubelet version: v1.17.2
docker version: 19.03.5
Ubuntu 18.04 desktop
Linux kernel version: 4.15.0-74-generic
I created an image with the docker build command on master node, and
confirmed that the image was deleted immediately with docker
container ls -a. If I running Docker only, the images have not been
deleted. So I guess the reason for the removal was due to the
kubernetes garbage collection. – MASH 3 hours ago
Honestly, I doubt that your recently build docker image could've been deleted by kubernetes garbage collector.
I think you are confusing two concepts: image and stopped container. If you want to check your local images, you should use docker image ls command, not docker container ls -a. The last one doesn't say anything about available images and doesn't prove that any image was deleted.
It's totally normal behaviour of Docker. Please look at this example from docker docs:
We build a new docker image using following commands:
# create a directory to work in
mkdir example
cd example
# create an example file
touch somefile.txt
# build an image using the current directory as context, and a Dockerfile passed through stdin
docker build -t myimage:latest -f- . <<EOF
FROM busybox
COPY somefile.txt .
RUN cat /somefile.txt
EOF
After successful build:
Sending build context to Docker daemon 2.103kB
Step 1/3 : FROM busybox
---> 020584afccce
Step 2/3 : COPY somefile.txt .
---> 216f8119a0e6
Step 3/3 : RUN cat /somefile.txt
---> Running in 90cbaa24838c
Removing intermediate container 90cbaa24838c
---> b1e6c2284368
Successfully built b1e6c2284368
Successfully tagged myimage:latest
we run:
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
As you can see there's nothing there and it's totally ok.
But when you run docker image ls command instead, you'll see our recently build image:
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
myimage latest b1e6c2284368 10 seconds ago 1.22MB
If you launch docker-run by yourself it works, if you do this with docker-compose it doesn't
roman#debian ~/D/O/devops> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
roman#debian ~/D/O/devops> docker-compose build app
Building app
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
roman#debian ~/D/O/devops>
Ok it's solved, previously been installing compose from repository, now installed through pip and it's working
I've been using Dockerfiles so often that I've forgotten how to start up a new one without one.
I was reading https://docs.docker.com/engine/reference/commandline/start/ and ofc it doesn't state how to start up a new one.
docker run -it ubuntu:16.04 bash
A Dockerfile describes a Docker image not a container.
The container is an instance of this image.
If you want to run a container without building an image (which means without creating a Dockerfile), you need to use an existing image on the Docker Hub (link here).
N.B.: The Docker Hub is a Docker online repository, they are more repositories like Quay, Rancher and others.
For example, if you want to test this, you can use the hello-world image found on the Docker Hub: https://hub.docker.com/_/hello-world/.
According to the documentation, to run a simple hello-world container:
$ docker run hello-world
Source: https://hub.docker.com/_/hello-world/
If you don't have the image locally, Docker will automatically pull it
from the web. If you want to manually pull the image you can run the
following command:
$ docker pull hello-world
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Source: https://hub.docker.com/_/hello-world/
docker start is used to start a stopped container which already exists and in stopped state.
If you want to start a new container use docker run instead. For information about docker run please see https://docs.docker.com/engine/reference/commandline/run/