docker: 'build' is not a docker command - docker

I was following https://cloud.google.com/container-registry/docs/quickstart documentation to build the Docker image;
Run the following Docker command from the directory containing the image's files:
docker build -t quickstart-image .
But then I get the error message:
docker: 'build' is not a docker command.
My docker version: version 18.09.0, build 4d60db4
Why is the command not working? Is it because of my docker version?

not sure if you still have this problem, but could you verify that there are no hidden characters in your
docker build -t quickstart-image .
I get this error when I copy-paste from either libre office or word
funny fix for funny problems

Related

Dockerfile exists but Docker says it can't locate

I don't see why docker doesn't build my Dockerfile. The Dockerfile is present but is complaining it can't locate it. What am I missing here? I'm at my wits end right now.
Dockerfile is present, unless my eyes are playing tricks on me. I think it's spelled correctly too.
$ ls
Dockerfile pct runme.sh
$
Error message I'm getting when running docker build
$ cat /tmp/context.tar | docker build -f Dockerfile -t iii -
Sending build context to Docker daemon 665.6kB
Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
$
So after playing with the docker build command, I got it working. I don't know how/why the person catted the tar file and then piped it to docker build but it worked for them but not for me.
The command that worked for me was:
$ docker build -f Dockerfile my_dir/ -t image_name

Hashicorp Packer "build" command is hanging in docker "run stage"

I am using,
Windows 10
Packer version : 1.8.4
Docker version 20.10.21, build baeda1f
When using any base image to build another docker image in packer using "packer build " command , the command aways gets hung in "docker run stage" , the logs are provided below :
$ packer build spark2223.prk.json
docker: output will be in this color.
==> docker: Creating a temporary directory for sharing data...
==> docker: Starting docker container...
docker: Run command: docker run -v C:\Users\mwandre\AppData\Roaming\packer.d\tmp2854382545:/packer-files -d -i -t --entrypoint=/bin/sh -- openjdk:8-jre-alpine
I am not sure how suddenly this problem started happening in my machine , untill yesterday it was working properly .
Any help would be apreciated .

Why isn't docker recognizing my "-f" option?

Following this post -- docker: "build" requires 1 argument. See 'docker build --help', I'm trying to build my docker image using a file with a non-traditional name ("local.Dockerfile") on Mac 10.13.6. I tried the below
localhost:mydir davea$ docker build -t mycontainer -f local.Dockerfile
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
But docker is choking on me. I'm running version 19.03.5.
Basic command to build docker image:
docker build -t <image_tag> -f <Dockerfile_name> <Path_of_Dockerfile>
So you are missing to specify the path of your local.Dockerfile (which is mandatory). If your dockerfile is in the current directory from where you are running the command, then run below command, else update the path accordingly:
docker build -t mycontainer -f local.Dockerfile .
Note: You can specify the Path_of_Dockerfile in any way: relative path or absolute path, whichever way you feel comfortable.

How to add the file in docker

I am new to docker, I installed docker as per the instructions provided in the official site.
# build docker images
docker build -t iky_backend:2.0.0 .
docker build -t iky_gateway:2.0.0 frontend/.
Now, while I am running these commands in the terminal after the installation of docker, I am getting the below error. I tried with by adding sudo also. But no use.
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/esh/Dockerfile: no such file or directory
Your docker images should execute just fine (may require sudo if you are unable to connect to docker daemon).
docker build requires a Dockerfile to present at the same directory (you are executing at your home folder - dont do that) or you need to use -f to specify the path instead of .
Try this:
mkdir build
cd build
create your Dockerfile here.
docker build -t iky_backend:2.0.0 .
docker images

Docker image versioning and lifecycle management

I am getting into Docker and am trying to better understand how it works out there in the "real world".
It occurs to me that, in practice:
You need a way to version Docker images
You need a way to tell the Docker engine (running on a VM) to stop/start/restart a particular container
You need a way to tell the Docker engine which version of a image to run
Does Docker ship with built-in commands for handling each of these? If not what tools/strategies are used for accomplishing them? Also, when I build a Docker image (via, say, docker build -t myapp .), what file type is produced and where is it located on the machine?
docker has all you need to build images and run containers. You can create your own image by writing a Dockerfile or by pulling it from the docker hub.
In the Dockerfile you specify another image as the basis for your image, run command install things. Images can have tags, for example the ubuntu image can have the latest or 12.04 tag, that can be specified with ubuntu:latest notation.
Once you have built the image with docker build -t image-name . you can create containers from that image with `docker run --name container-name image-name.
docker ps to see running containers
docker rm <container name/id> to remove containers
Suppose we have a docker file like bellow:
->Build from git without versioning:
sudo docker build https://github.com/lordash/mswpw.git#fecomments:comments
in here:
fecomments is branch name and comments is the folder name.
->building from git with tag and version:
sudo docker build https://github.com/lordash/mswpw.git#fecomments:comments -t lordash/comments:v1.0
->Now if you want to build from a directory: first go to comments directory the run command sudo docker build .
->if you want to add tag you can use -t or -tag flag to do that:
sudo docker build -t lordash . or sudo docker build -t lordash/comments .
-> Now you can version your image with the help of tag:
sudo docker build -t lordash/comments:v1.0 .
->you can also apply multiple tag to an image:
sudo docker build -t lordash/comments:latest -t lordash/comments:v1.0 .

Resources