I'm ready to deploy my website in windows docker container,
In this script : [ docker-compose up ] , everything is fine, I can reach my web;
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
image: haltan1118/aspdotnetcore:1.0.0
deploy:
replicas: 5
resources:
limits:
cpus: "0.5"
memory: 250M
restart_policy:
condition: on-failure
ports:
- "8111:80"
networks:
- webnet
networks:
webnet:
docker-compose up
compose_script
good_website
but if I build it with script [Docker Stack Deploy],
docker shows website's running status is ok, every point is running, but I can't reach them !
And system has no logs to check this problem.
docker stack deploy -c docker-compose.yml mywebtest
stack_deploy_status
bad_website
Related
I'm trying to use the loki log driver in a docker container on an AWS ec2 host. The config below works fine on my own ubuntu 20.04 machine but not in an ubuntu 16.04 ec2 host. iptables has a loopback rule and the appropriate docker port for loki, :3100. I even opened up that port in the security group. The docker version is 20.10.2.
I have tried to use localhost:3100, the hostname:3100, also the docker container name. I have a bridge network and don't want to use a host network. I also don't want to use the container IP address.
Nothing in this SO question works for me. How to access host port from docker container
Here is my docker-compose.yaml which works on my local machine but not in ec2.
the tools container is a go html server. The tools and loki containers are on the same host.
I can post a log to loki from an alpine container using curl to URL http://loki:3100/loki/api/v1/push but not from my tools container. I can connect with telnet but curl times out.
version: '3.3'
networks:
traefik:
external: true
loki: {}
services:
tools:
build: .
container_name: tools
restart: always
networks:
- traefik
- loki
extra_hosts:
- "host.docker.internal:host-gateway"
logging:
driver: loki
options:
loki-url: http://loki:3100/loki/api/v1/push
loki-external-labels: job=tools
labels:
...
Here is my loki docker-compose.yaml
version: "3.8"
networks:
traefik:
external: true
loki: {}
volumes:
loki_data:
services:
loki:
container_name: "loki"
image: grafana/loki:2.1.0
restart: always
networks:
- traefik
- loki
ports:
- 3100:3100
volumes:
- type: volume
source: loki_data
target: /data
- type: bind
source: ./config/s3-loki-bolt-conf.yml
target: /etc/loki/local-config.yaml
command: -config.file=/etc/loki/local-config.yaml
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
the docker plugin is installed
docker plugin ls
ID NAME DESCRIPTION ENABLED
a03c22e8375e loki:latest Loki Logging Driver true
sudo journalctl -u docker.service | grep loki is giving me this error.
08 06:46:06 docker1 dockerd[30842]: time="2021-02-08T06:46:06-08:00" level=info msg="level=warn ts=2021-02-08T14:46:06.586642758Z caller=client.go:322 container_id=5a5fbd8a7077243de9db74f549ab619f783eda978ee234651ad1849263a534fe component=client host=localhost:3100 msg=\"error sending batch, will retry\" status=-1 error=\"Post \\\"http://localhost:3100/loki/api/v1/push\\\": context deadline exceeded\"" plugin=fef8734ec8cc2d252f8c4e73e3e91fe8293d2847c7ce1d6df2fb2172a1c288ce
I have an app that is working but I am getting problems to make it run on Azure.
I have the next docker-compose
version: "3.6"
services:
nginx:
image: nginx:alpine
volumes:
- ./:/var/www/
- ./setup/azure/nginx/conf.d/:/etc/nginx/template
environment:
PORT: ${PORT}
command: /bin/sh -c "envsubst '$${PORT}' < /etc/nginx/template/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
networks:
- mynet
depends_on:
- app
- worker
app:
image: myimage:latest
build:
context: .
dockerfile: ./setup/azure/Dockerfile
restart: unless-stopped
tty: true
expose:
- 9000
volumes:
- uploads:/var/www/simple/public/uploads
- logos:/var/www/simple/public/logos
networks:
- mynet
worker:
image: my_image:latest
command: bash -c "/usr/local/bin/php artisan queue:work --timeout=0"
depends_on:
- app
networks:
- mynet
volumes:
uploads:
logos:
networks:
mynet:
I am unsure if the volumes in nginx ok, I think that perhaps I should create a new Dockerfile to copy the files. However, this would increase a lot the size of the project.
When using App Services on azure the development is made assigning a randomly port, that's wgy i have the envsubst instruction in command. I appreciate any other suggestion to make it run this project on Azure
I'm assuming you're trying to persist the storage in your app to a volume. Check out this doc issue. Now I don't think you need
volumes:
- ./:/var/www/
- ./setup/azure/nginx/conf.d/:/etc/nginx/template
but for
volumes:
- uploads:/var/www/simple/public/uploads
- logos:/var/www/simple/public/logos
you can create a storage account, mount it to your linux app plan (it's not available for Windows app plans yet), and mount the relative path /var/www/simple/public/uploads to the file path of the storage container.
I am scaling multiple containers of a service on a single linux host by command "docker-compose up --scale". However, each container can use all the resources (CPU and RAM) of the host. It seems to be useless to scale like that.
Thus, I try to limit availabe CPU and RAM for each container (I am currently using docker-compose version 2) by "cpus" and "mem_limit" tag in docker-compose.yml file.
This is my docker-compose.yml file
version: "2.2"
services:
test:
image: test
mem_limit: 500000000
container_name: test
build: ./test
restart: always
mem_limit: 500000000
mem_reservation: 300m
cpus: 0.5
networks:
- test-network
ports:
- "9000:80"
But I don't know that if it is useful to scale multiple containers of a service on a single host? Also, is there any ways to automatically scale this service (scale on demand)?
Thank you,
version: "3"
services:
test:
image: test
deploy:
replicas: 5
resources:
limits:
cpus: "0.5"
memory: 500M
restart_policy:
condition: always
ports:
- "9000:80"
networks:
- test-network
networks:
test-network:
docker swarm init #Initialize machine as docker swarm manager
docker stack deploy -c docker-compose.yml testing #This will start 5 containers for the same image as replica
You can scale the app by changing the replicas to 6 value in docker-compose.yml, saving the change, and re-running
docker stack deploy -c docker-compose.yml testing #Docker performs an in-place update, no need to tear the stack down first or kill any containers
For detailed explanation you can follow this article, https://docs.docker.com/get-started/part3/.
But i suggest you to start with first part of this tutorial.
And for any docker experiments you can try https://labs.play-with-docker.com/
I'm using docker for windows (Version 18.03.0-ce-win59 (16762)) in a windows 10 pro. All the containers run ok after running the command docker-compose -up -d. The problem is when I restart the docker service. Then, once restarted, all the containers are stoped and when I run the command docker-compose start -d the following error is shown:
Error response from daemon: network ccccccccccccc not found
I don't know what's happening. When I run the container using run and the --restart=always option everything works as expected. No error is shown on restart.
This is the docker-compose file:
version: '3'
services:
service_1:
image: image1
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "1"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
service_2:
image: image2
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "2"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
service_3:
image: image3
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "4"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
The dockerfiles are like this:
FROM microsoft/dotnet-framework:3.5
ARG ENTRY
ENV my_env=$ENTRY
WORKDIR C:\\foo2
ENTRYPOINT C:/foo2/app.exe %my_env%
The network has changed. I used docker network prune command to meet the same problem.Recreate the container would fix the problem. Docker would set up the network again for the new containers.
#remove all containers
docker rm $(docker ps -qa)
#or
docker system prune
There might be some old container instances which were not removed. Check the instances with
docker container ls -a
You might get output like this if you have some instances which were not removed
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b4678e6666b b4a75a01d539 "/bin/sh -c 'eval `s…" 6 weeks ago Exited (1) 6 weeks ago zealous_allen
ee862a3418f2 1eaaf48e9b42 "/bin/sh -c 'eval `s…" 6 weeks ago Exited (1) 6 weeks ago jolly_torvalds
Remove the containers by the container id
docker container rm 8b4678e6666b
docker container rm ee862a3418f2
Now start your container with docker-compose file
This worked for me. Hope it helps!
I found a possible solution editing the docker-compose.yml file as follows:
version: '3'
services:
cm04:
image: tnc530_cm04
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC530
dockerfile: Dockerfile
args:
ENTRY: "1"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC530/bin/x86/Release:C:/adontec
cm06:
image: tnc620_cm06
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620
dockerfile: Dockerfile
args:
ENTRY: "2"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620/bin/x86/Release:C:/adontec
cm08:
image: tnc620_cm08
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620
dockerfile: Dockerfile
args:
ENTRY: "4"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620/bin/x86/Release:C:/adontec
networks:
test:
external:
name: nat
As you can see I created a network called test linked with the external network nat. Now, when I restart the docker services the containers are started with no errors.
Alternatively, you can just open your docker app and manually delete the containers. Then run docker-compose up on your terminal. Now it should be working. Go to the port either 9000 or 9001 or whichever port you are using and see if minio is actually running.
Use this way to deploy an application which has been built as a docker image hosted on ecr:
version: "3"
services:
web:
image: [AWS_ECR_REPO_URL]/app0:latest
deploy:
replicas: 5
restart_policy:
condition: on-failure
resources:
limits:
cpus: "0.1"
memory: 50M
ports:
- "80:80"
networks:
- webnet
networks:
webnet:
Deploy it:
$ docker stack deploy -c docker-compose.yml app0
Then use docker images to check the images local, can't find the [AWS_ECR_REPO_URL]/app0:latest at all.
If pull the repo myself, it can be get:
$ docker pull [AWS_ECR_REPO_URL]/app0:latest
I don't know why.
Enter your credentials using docker login if you want to pull the private image.
Specify server name want to login into self-hosted registry
docker login server-name (localhost)
Use --with-registry-auth option for swarm
docker stack deploy --with-registry-auth