I have a local docker image which has name img_test
. My docker-compose.yml
file is:
version: '2'
services:
img_test:
image: img_test:latest
ports:
- "8080:80"
mysql:
image: mysql:latest
ports:
- "3636:3036"
nvidia/cuda:
image: nvidia/cuda:latest
runtime: nvidia
command: nvidia-smi
networks:
appnet:
external: true
I also have Dockerfile
. When I run the command docker-compose up
It throws this error.
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid service name 'img_test' - only [a-zA-Z0-9\._\-] characters are allowed
I gave another names such as img/test
, imgtest
but they did not work.
I also tried build the Dockerfile
in docker-compose.yml
file by this command.
version: '2'
services:
app:
build: .
It gives same error for app
.
What is the solution? I am new on Docker
. I tested my image and it is working correctly. I dont want to push my image to Dockerhub. Is there another way to solve this problem?
It's a relatively old version of docker-compose. They had this bug in the past. Try upgrading.