how to solve docker error of "Cannot locate specified Dockerfile: Dockerfile" - docker

I'm following this link to making a docker-compose.yml file but it will giving me the same issue does not find the docker file while I'm mentioning that in the docker-compose.yml see my code:-
version: '2'
services:
web:
build: .
ports:
- "8000:8000"
users:
build:
context: ./users
dockerfile: Dockerfile
image: cinema/movies
container_name: cinema-movies
environment:
VIRTUAL_HOST: movies.local
And docker-compose.yml file is in the bkapiv folder the folder structure is :-
bkapiv(Folder)------users(Folder)
| |
| ------Dockerfile
|
---------docker-compose.yml
How will I resolve my issue that I will run my first api on local using docker.

web:
build: .
I think error throwing from web container, commented out the users and run the docker-compose, you need a Dockerfile in web too. Also try other way around. The you can understand which container produce the error. Because users looks fine for me according to your folder structure. Plus you have an extra space in services:

The problem is in the web service, you specified that it should build a Dockerfile in your current dir but there is no Dockerfile there.

Related

Docker Drupal 8: ERROR: Cannot locate specified Dockerfile: Dockerfile

I already followed different stackoverflow post, but still getting this issue. I am running Drupal 8 and moving project to Docker.
So on root I have created docker-compose.yml I have created file & below is my content
version: '3'
services:
mysql:
image: mysql:5.7
container_name: drupal-mysql
environment:
MYSQL_DATABASE: drupal
MYSQL_USER: root
MYSQL_PASSWORD: root
volumes:
- db_data:/var/lib/mysql:delegated
restart: always
drupal:
image: drupal:latest
container_name: drupal
depends_on:
- mysql
build: .
ports:
- "8080:80"
volumes:
- ./drupal:/drupal
restart: always
volumes:
db_data:
While running docker-compose up -d --build it gives
Building drupal
ERROR: Cannot locate specified Dockerfile: Dockerfile
In the definition of the drupal service build: . is telling docker compose that the relative Dockerfile should be in the same directory where docker-compose.yml is.
Make sure the path is correct or change it accordingly, the path is relative to the docker file location.
Please, check the compose file build and context sections for further details.
You need to remove build command (which is after depends_on) from your drupal service section of docker-compose file.
Since you are already providing image, you need not build it. So you can just run docker-compose up without --build arg.
If you need to build 'drupal' service then you need to provide build information with (buildContext as current directory in most cases and dockerfile).

Trying to connect"neither an image nor a build context specified."

Running docker-compose commands like build and up works.
However when I try to connect docker with VS Code I get this error:
The Compose file is invalid because:
Service your-service-name-here has neither an image nor a build context specified. At least one must be provided.
This is the compose file:
version: '3'
services:
db:
image: postgres
ports:
- "5432:5432"
web:
build: .
command: bin/rails server --port 3000 --binding 0.0.0.0
ports:
- "3000:3000"
links:
- db
volumes:
- .:/myapp
Look at your devcontainer.json in the .devcontainer folder. Mine had an autogenerated docker-compose.yml from a previous experiment and it was a partially-filled template which could not work, hence the error message.
Found this by looking carefully at the command VSCode was trying to execute (the -f argument).
Cleaning up the .json config file solved the issue.
I very probably that your should be specific build context
build:
context: . # if you stay on root project

Docker. Symlink INSIDE context not working

I've simplified setup for demonstration purposes, but I don't understand why this issue happens. What do I miss.
Project folder content
current -> releases/21
releases
inside releases/21 project with docker-compose.yml is located.
Here is the abridged version of my docker-compose.yml
version: '3'
services:
app:
container_name: app
build:
context: ../
dockerfile: ./current/docker/app.docker
Of course, app.docker is there.
And still I receive this error
ERROR: Cannot locate specified Dockerfile: current/docker/app.docker
After running docker-compose up -d in the <project_folder>/current.
It works with an absolute path.
Something like this will work, but I still feel, that it's not a solution
version: '3'
services:
app:
container_name: app
build:
context: /var/www/<project-name>
dockerfile: ./current/docker/app.docker

Are docker environment variables shared between containers?

Newbie here. I created an empty solution, added WebApplication1 and WebApplication2. I then added docker support (Docker for Windows, Windows Containers). Compose file looks like this:
version: '3.4'
services:
webapplication1:
image: compositeapp
build:
context: .\WebApplication1
dockerfile: Dockerfile
webapplication2:
image: compositeapp
build:
context: .\WebApplication2
dockerfile: Dockerfile
So both containers are in a single image. Webapplication1 dockerfile has ENV LICENSE=abc123 and webapplication2 dockerfile has ENV LICENSE=abc456.
After building and starting the containers, I used exec -it powershell to remote into the 2 containers and did get-item env:license. Both containers returned 456.
As a newbie, I was expecting one machine to return abc123 and the other abc456. I just made up the environment name as being license, but what does one do if they need a per container environment variable?
I guess the issue you notice provides from the fact you specified the same image name for both services, which implies that they will have the same ENV variable as defined in the latest-compiled Dockerfile.
Could you try this instead?
version: '3.4'
services:
webapplication1:
image: compositeapp1
build:
context: .\WebApplication1
dockerfile: Dockerfile
webapplication2:
image: compositeapp2
build:
context: .\WebApplication2
dockerfile: Dockerfile
Anyway, even if this is working, I assume your two Dockerfile are almost the same (?), in which case I would rather suggest to use a single Dockerfile and a single image tag, but customize the environment of both services by using some environment section in your docker-compose.yml (or some env_file section, along with some external .env files...).
For example, you may want to write something like this:
version: '3.4'
services:
webapplication1:
image: compositeapp
build:
context: .\WebApplication
dockerfile: Dockerfile
environment:
- LICENSE=abc123
webapplication2:
image: compositeapp
environment:
- LICENSE=abc456
(not forgetting to remove the ENV LICENSE=... line from the Dockerfile)

build contains unsupported option: 'ports'

Trying to use docker-compose for the first time, but not having much luck. I have the following setup:
docker-compose version 1.8.0, build f3628c7
/home/GabeThermComposer contains the docker-compose.yml
/home/GabeThermComposer/GabeThermApache contains Dockerfile
/home/GabeThermComposer/GabeThermPHPMyAdmin contains Dockerfile
/home/GabeThermComposer/GabeThermDB contains Dockerfile and nest-init.sql
When I create docker images using the Dockerfile in each subdir, it all works without issues. I was hoping with the docker-compose.yml to do all the seperate building of images at once.
The docker-compose.yml looks like this:
version: '2'
services:
GabeThermDB:
build:
context: ./GabeThermDB
dockerfile: Dockerfile
GabeThermApache:
build:
context: ./GabeThermApache
dockerfile: Dockerfile
ports:
- "80:80"
GabeThermPHPMyAdmin:
build:
context: ./GabeThermPHPMyAdmin
dockerfile: Dockerfile
ports:
- "8080:80"
When trying to run "docker-compose up", I get the following error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.GabeThermPHPMyAdmin.build contains unsupported option: 'ports'
services.GabeThermApache.build contains unsupported option: 'ports'
I have no clue on what is wrong with this. I think I did exactly as other examples have shown. Btw, I do know that the "context:" and "dockerfile:" is overdone, but since I'm new, I wanted to be sure to what files I'm pointing in case I forget it automatically dives into the subdir and runs the Dockerfile.
Any help is appreciated.
You have to move the ports out of the build block.
version: '2'
services:
GabeThermDB:
build:
context: ./GabeThermDB
dockerfile: Dockerfile
GabeThermApache:
build:
context: ./GabeThermApache
dockerfile: Dockerfile
ports:
- "80:80"
GabeThermPHPMyAdmin:
build:
context: ./GabeThermPHPMyAdmin
dockerfile: Dockerfile
ports:
- "8080:80"

Resources