When I ran: COMPOSE_PROJECT_NAME=zk_test docker-compose up
, I got error saying
«ERROR: In file ‘./docker-compose.yml’, service must be a mapping, not
a NoneType.».
This is my yml file:
version: '2'
services:
zoo1:
image: zookeeper
restart: always
container_name: zoo1
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2:
image: zookeeper
restart: always
container_name: zoo2
ports:
- "2182:2181"
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3:
image: zookeeper
restart: always
container_name: zoo3
ports:
- "2183:2181"
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
Sample Image:
Chris Snow
23.1k33 gold badges136 silver badges297 bronze badges
asked Apr 17, 2017 at 13:27
1
YAML is indentation dependent. This
services:
zoo1:
is a mapping with two keys that both map to null
(i.e. None
in Python).
Whereas:
services:
zoo1:
is a mapping nested in a mapping. The key ‘services’ has as value a mapping with key zoo1
(which again has a value null
).
answered Apr 17, 2017 at 22:20
AnthonAnthon
65.7k29 gold badges179 silver badges236 bronze badges
1
version: '2'
services:
autodiscovery:
build: ./autodiscovery/
mem_limit: 128m
expose:
- 53
- 8300
- 8301
- 8302
- 8400
- 8500
ports:
- 8500:8500
dns:
- 127.0.0.1
just put one space. before.
helvete
2,33510 gold badges37 silver badges36 bronze badges
answered Jun 21, 2020 at 14:56
Synopsis
When I was building the environment with Docker, I encountered such a build error.
ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType.
Post a memorandum on how to deal with this error and why it occurred.
Reason for error
Because the indentation is inappropriate. Probably some half-width space is missing.
solution
Suppose you get an error in docker-compose.yml like this.
Example
version: "3"
services:
react-navigation:
build: ./
volumes:
- ./react-navigation/:/usr/src/app
env_file: .env
command: bash -c "cd example && yarn start"
ports:
- "19000:19000"
- "19001:19001"
- "19002:19002"
As a solution, add two half-width spaces under react-navigation and change it like this.
version: "3"
services:
react-navigation:
build: ./
volumes:
- ./react-navigation/:/usr/src/app
env_file: .env
command: bash -c "cd example && yarn start"
ports:
- "19000:19000"
- "19001:19001"
- "19002:19002"
Afterword
Probably an error that people who have just learned Docker will encounter.
I hope this article will be useful for those people and myself.
#mongodb #docker #yaml
Вопрос:
Как я могу решить эту проблему/ошибку?
ОШИБКА: В файле». /docker-compose.yml » служба должна быть отображением, а не типом.
Я не уверен, почему, но я не могу понять мир yml, файл yml находится здесь:
1 version: "3.8"
2 services:
3 mongodb:
4 image: mongo
5 container_name: mongodb
6 environment:
7 - MONGO_INITDB_ROOT_USERNAME=microservice
8 - MONGO_INITDB_ROOT_PASSWORD=A1d2r3i4a5n!
9 volumes:
10 - mongodb-data:/data/db
11 networks:
12 - mongodb_network
13 ports:
14 - 27017:27017
15 healthcheck:
16 test: echo 'db.runCommand("ping").ok' | mongo 192.168.254.135:27017/test --quiet
17 interval: 30s
18 timeout: 10s
19 retries: 3
20 restart: unless-stopped
21 mongo-express:
22 image: mongo-express
23 container_name: mongo-express
24 environment:
25 - ME_CONFIG_MONGODB_SERVER=mongodb
26 - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
27 - ME_CONFIG_MONGODB_ADMINUSERNAME=microservice
28 - ME_CONFIG_MONGODB_ADMINPASSWORD=A1d2r3i4a5n!
29 - ME_CONFIG_BASICAUTH_USERNAME=admin
30 - ME_CONFIG_BASICAUTH_PASSWORD=admin123
31 volumes:
32 - mongodb-data
33 depends_on:
34 - mongodb
35 networks:
36 - mongodb_network
37 ports:
38 - 8081:8081
39 healthcheck:
40 test: wget --quiet --tries=3 --spider http://admin:admin123@192.168.254.135:8081 || exit 1
41 interval: 30s
42 timeout: 10s
43 retries: 3
44 restart: unless-stopped
45 volumes:
46 mongodb-data:
47 name: mongodb-data
48 networks:
49 mongodb_network:
50 name: mongodb_network
Ответ №1:
Проблема возникает из-за вашего отступа. Проверьте ссылку на docker-compose и синтаксис YAML.
Ваше определение должно выглядеть примерно так:
1 version: "3.8"
2 services:
3 mongodb:
4 image: mongo
5 container_name: mongodb
6 environment:
7 - MONGO_INITDB_ROOT_USERNAME=microservice
8 - MONGO_INITDB_ROOT_PASSWORD=A1d2r3i4a5n!
9 volumes:
10 - mongodb-data:/data/db
11 networks:
12 - mongodb_network
13 ports:
14 - 27017:27017
15 healthcheck:
16 test: echo 'db.runCommand("ping").ok' | mongo 192.168.254.135:27017/test --quiet
17 interval: 30s
18 timeout: 10s
19 retries: 3
20 restart: unless-stopped
21 mongo-express:
22 image: mongo-express
23 container_name: mongo-express
24 environment:
25 - ME_CONFIG_MONGODB_SERVER=mongodb
26 - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
27 - ME_CONFIG_MONGODB_ADMINUSERNAME=microservice
28 - ME_CONFIG_MONGODB_ADMINPASSWORD=A1d2r3i4a5n!
29 - ME_CONFIG_BASICAUTH_USERNAME=admin
30 - ME_CONFIG_BASICAUTH_PASSWORD=admin123
31 volumes:
32 - mongodb-data:/data/db
33 depends_on:
34 - mongodb
35 networks:
36 - mongodb_network
37 ports:
38 - 8081:8081
39 healthcheck:
40 test: wget --quiet --tries=3 --spider http://admin:admin123@192.168.254.135:8081 || exit 1
41 interval: 30s
42 timeout: 10s
43 retries: 3
44 restart: unless-stopped
45
46 volumes:
47 mongodb-data:
48
49 networks:
50 mongodb_network:
Комментарии:
1. последовал за ним, все еще получая
ERROR: In file './docker-compose.yml', network 'name' must be a mapping not a string.
и после запуска yamllint « 40:81 строка ошибки слишком длинная (92 > 80 символов) (длина строки)«появляется эта ошибка2. теперь получаем
ERROR: The Compose file './docker-compose.yml' is invalid because: services.mongo-express.healthcheck value 'restart' does not match any of the regexes: '^x-' services.mongodb.healthcheck value 'restart' does not match any of the regexes: '^x-'
3. да,
restart
это не является частьюhealthcheck
сопоставления. Это должны быть сервисы.монго-экспресс.перезапуск. Я отредактирую исходный ответ4. также
networks.mongodb-data.name
не является допустимым ключом. Я также отредактировал это в исходном ответе. И вы не указали, где вы монтируетеmongodb-data
дляmongo-express
службы. Я поставил/data/db
, но, может быть, вам стоит его настроить.
-
2
0
Votes2
Posts0
Views1208874.dockerfile# File : 1208874.dockerfile
# Modified : <2020-11-24 Tue 09:56:18 GMT>
# URL : https://ru.stackoverflow.com/questions/1208874/
ARG LOGIN_PASSWORD
FROM ubuntu:latest
ARG LOGIN_PASSWORD
ENV LOGIN_PASSWORD=$LOGIN_PASSOWRD
RUN apt update && apt install openssh-server -y
RUN echo «#!/bin/bash n env; echo ‘root:$LOGIN_PASSWORD’ | chpasswd; service ssh start; service ssh status» > ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
EXPOSE 22
ENTRYPOINT [«./entrypoint.sh»]
CMD [«/usr/sbin/sshd»,»-D»]
End of 1208874.dockerfile
Let’s get started.docker build —file 1208874.dockerfile —tag 1208874:latest .
docker run -d —env «LOGIN_PASSWORD=1234» —publish 2222:22 1208874:latest -
2
0
Votes2
Posts0
ViewsO
Try this:version: ‘3.5’
services:
MYSQL
db:
image: mysql
container_name: db_mysql
command: —default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: «admin»
ports:
— 3306:3306
networks:
— mysql_net
adminer:
image: adminer
restart: always
ports:
— 8081:8080
networks:
— mysql_net
POSTGRES
postgres:
image: postgres
container_name: postgres
environment:
POSTGRES_PASSWORD: admin
ports:
— «5432:5432»
networks:
— mysql_net
pgadmin4:
image: dpage/pgadmin4
container_name: pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: pgadmin@pgadmin.com
PGADMIN_DEFAULT_PASSWORD: admin
ports:
— «15432:80»
networks:
— mysql_net
networks:
mysql_net:
name: mysql_net
driver: bridge
— (other compose)version: ‘3.5’
services:
nginx:
image: richarvey/nginx-php-fpm
ports:
— «8080:80»
container_name: nginx
volumes:
— ./code:/var/www/html
networks:
— mysql_net
networks:
mysql_net:
name: mysql_net -
2
0
Votes2
Posts0
ViewsYour manifestation:<?xml version=»1.0″ encoding=»utf-8″?>
<uses-sdk
android:minSdkVersion=»15″
android:targetSdkVersion=»23″ />
<uses-permission android:name=»android.permission.INTERNET» />
<uses-permission android:name=»android.permission.CALL_PHONE» />
<uses-permission android:name=»android.permission.WRITE_EXTERNAL_STORAGE» />
<!— To auto-complete the email text field in the login form with the user’s emails —>
<uses-permission android:name=»android.permission.GET_ACCOUNTS» />
<uses-permission android:name=»android.permission.READ_PROFILE» />
<uses-permission android:name=»android.permission.READ_CONTACTS» />
<service android:name=»info.androidhive.firebase.MyFirebaseMessagingService» >
<intent-filter>
<action android:name=»com.google.firebase.MESSAGING_EVENT» />
</intent-filter>
</service>
<uses-permission android:name=»com.github.hathibelagal.pn.permission.C2D_MESSAGE» />
<uses-permission android:name=»android.permission.ACCESS_NETWORK_STATE» /> <!— Optional permission for App measurement to run. —>
<uses-permission android:name=»android.permission.WAKE_LOCK» />
<uses-permission android:name=»com.google.android.c2dm.permission.RECEIVE» />
<permission
android:name=»info.androidhive.firebase.permission.C2D_MESSAGE»
android:protectionLevel=»signature» />
<uses-permission android:name=»info.androidhive.firebase.permission.C2D_MESSAGE» />
<application
android:allowBackup=»true»
android:debuggable=»true»
android:icon=»@mipmap/ic_launcherb»
android:label=»@string/app_name»
android:supportsRtl=»true»
android:testOnly=»true»
android:theme=»@style/AppTheme» >
<activity
android:name=»info.androidhive.firebase.LoginActivity»
android:theme=»@style/AppTheme.NoActionBar» >
<intent-filter>
<action android:name=»android.intent.action.MAIN» />
<category android:name=»android.intent.category.LAUNCHER» />
</intent-filter>
</activity>
<activity
android:name=»info.androidhive.firebase.MainActivity»
android:label=»@string/title_activity_profile»
android:theme=»@style/AppTheme.NoActionBar» />
<activity
android:name=»info.androidhive.firebase.SignupActivity»
android:label=»@string/title_activity_login»
android:theme=»@style/AppTheme.NoActionBar» />
<activity
android:name=»info.androidhive.firebase.ResetPasswordActivity»
android:label=»@string/title_activity_reset_password»
android:theme=»@style/AppTheme.NoActionBar» />
<activity
android:name=»info.androidhive.firebase.Calculate»
android:parentActivityName=»info.androidhive.firebase.MainActivity» />
<activity
android:name=»info.androidhive.firebase.Hipoglucemia»
android:parentActivityName=»info.androidhive.firebase.MainActivity» />
<activity
android:name=»info.androidhive.firebase.Hitorial»
android:parentActivityName=»info.androidhive.firebase.MainActivity» />
<activity android:name=»info.androidhive.firebase.Hitorial2″ />
<activity
android:name=»info.androidhive.firebase.History»
android:parentActivityName=»info.androidhive.firebase.MainActivity» />
<!—
FirebaseMessagingService performs security checks at runtime,
no need for explicit permissions despite exported=»true»
—>
<service
android:name=»com.google.firebase.messaging.FirebaseMessagingService»
android:exported=»true» >
<intent-filter android:priority=»-500″ >
<action android:name=»com.google.firebase.MESSAGING_EVENT» />
</intent-filter>
</service><receiver
android:name=»com.google.android.gms.measurement.AppMeasurementReceiver»
android:enabled=»true» >
<intent-filter>
<action android:name=»com.google.android.gms.measurement.UPLOAD» />
</intent-filter>
</receiver><service
android:name=»com.google.android.gms.measurement.AppMeasurementService»
android:enabled=»true»
android:exported=»false» /><activity
android:name=»com.google.android.gms.common.api.GoogleApiActivity»
android:exported=»false»
android:theme=»@android:style/Theme.Translucent.NoTitleBar» /><receiver
android:name=»com.google.firebase.iid.FirebaseInstanceIdReceiver»
android:exported=»true»
android:permission=»com.google.android.c2dm.permission.SEND» >
<intent-filter>
<action android:name=»com.google.android.c2dm.intent.RECEIVE» />
<action android:name=»com.google.android.c2dm.intent.REGISTRATION» /><category android:name=»info.androidhive.firebase» />
</intent-filter>
</receiver><receiver
android:name=»com.google.firebase.iid.FirebaseInstanceIdInternalReceiver»
android:exported=»false» /><service
android:name=»com.google.firebase.iid.FirebaseInstanceIdService»
android:exported=»true» >
<intent-filter android:priority=»-500″ >
<action android:name=»com.google.firebase.INSTANCE_ID_EVENT» />
</intent-filter>
</service><provider
android:name=»com.google.firebase.provider.FirebaseInitProvider»
android:authorities=»info.androidhive.firebase.firebaseinitprovider»
android:exported=»false»
android:initOrder=»100″ /><meta-data
android:name=»com.google.android.gms.version»
android:value=»@integer/google_play_services_version» /><provider
android:name=»com.android.tools.ir.server.InstantRunContentProvider»
android:authorities=»info.androidhive.firebase.com.android.tools.ir.server.InstantRunContentProvider»
android:multiprocess=»true» /></application>
-
2
0
Votes2
Posts0
ViewsK
According to the documentation you would have to access the daemon.json where the default bridge is defined and modify the settings you need. It should be something like that by default in your case:{
«bip»: «192.168.99.100/24»,
«fixed-cidr»: «192.168.99.100/25»,
«fixed-cidr-v6»: «2001:db8::/64»,
«mtu»: 1500,
«default-gateway»: «192.168.1.1»,
«default-gateway-v6»: «2001:db8:abcd::89»,
«dns»: [«10.20.1.2″,»10.20.1.3»]
}
You’d have to modify it by ips if they accepted your company’s firewall.Here you can find information about where and how to modify the daemon.js in Windows: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon -
2
0
Votes2
Posts0
ViewsT
It’s standard shell variable surgery. In this case, the impact will be 127.0.0.1 if the variable DOCKER_HOST_IP Not declared ( empty). Details can be read, for example https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_10_03.html
-
2
0
Votes2
Posts0
ViewsY
You don’t have him in public, and it’s also like a full-time judge, it’s in another class, so the ui-freymworth can’t create a copy of it.Take this class to a separate java file and add the retrofit. publicP. S. The library doesn’t have a public class either. But the inflator, in handling the marking file, creates copies of the classes through the reflexia, so this code can be compromised and’ll even work, but it’s best not to do it — you can get a sudden mistake and then you can find a reason for a long time.
-
2
0
Votes2
Posts0
ViewsE
<form method=»post» action=»<?=$_SERVER[‘PHP_SELF’]?>»>
</form> -
2
0
Votes2
Posts0
ViewsK
Apparently, your ID’s wrong. The yml files use tabs or spaces to delimit blocks similar to python.container_name, volumes, expose,ports, environment and restart are out of kwan.Try to adjust to version: ‘3’
services:
kwan:
image: postgres:11.5
network_mode: bridge
container_name: postgres
volumes:
— postgres-data:/var/lib/postgresql/data
expose:
— 5432
ports:
— 5432:5432
environment:
— POSTGRES_PASSWORD=root
— POSTGRES_USER=postgres
— POSTGRES_DB=root
restart: unless-stopped
backend:
build: .
I think that will solve -
2
0
Votes2
Posts0
ViewsR
How are you simply using one host docker and IIS is not a container/service, the solution would be to get your IIS to access host docker.How docker-created networks are virtual, both default as any other explicitly created, directly only host and the docker themselves told to know it, which prevents, by default, the server hosting the IIS from having access to any docker-managed network, but more easily to the host docker.So, publishing the doors for access by host — —publish , -p or —publish-all , -P, considering that you are using the docker CLI — would be the alternative for you to create the routes on your HTTP server.When using Swarm there are some alternatives like https://docs.docker.com/engine/swarm/ingress/ that facilitates access by resources outside Swarm.
-
2
0
Votes2
Posts0
ViewsJ
Unfortunately Docker on Windows is not so good, because it has to emulate a linux machine to serve the kernel for the images and only then use the concept of container and batteries, and another thing I noticed is that especially Windows 10 recently is slower than normal for Docker, I say that because I already use Docker over 3 years, as the Docker for believe windows is relatively new and windows 10 is with several problems But summarizing about performance doesn’t have much to do, in this link a discussion was opened to help people with this problem and the developers manage to help, I hope it is useful https://github.com/docker/for-win/issues/1936
-
2
0
Votes2
Posts0
ViewsS
If you want to access the Jupyter Notebook running inside the Docker container via the port from the local machine, you need to connect the port inside the container and the port of the local machine.Jupyter jupyter/scipy-notebook Images on startup http://docs.docker.jp/engine/reference/run.html#expose Using the following startup method https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html Homedocker run -p 8888:8888 jupyter/scipy-notebook:2c80cf3537ca
I don’t know what kind of image the questioner is making, but if you don’t want to publish the port at least, you shouldn’t be able to access inside the container via the port. -
2
0
Votes2
Posts0
ViewsThe root cause of this issue was the absence of the relay-log option in the mysql.cnf file (or in this case, due to the docker volume mounts, the docker.cnf file). This lead to the creation and usage of files such as 89726507f176-relay-bin.000002 initially, where 89726507f176 is the host name of the machine (randomly assigned by the docker daemon when an image is created). When the container was stopped, removed and recreated, a new set of files was created and used (e.g. be0c801d95bc-relay-bin.000407) but this caused sync issues.
By explicitly specifying a value for relay-log in the docker.cnf file the container was able to be removed and recreated without problems.
As a side note, I suggested also that there was a problem with the /var/log/mysql directory not being mounted — this is not the case. If however you specify a value of log_bin = /var/log/mysql/mysql-bin.log for example, then this is a requirement. If you do not specify this path, it seems the binary logs are stored locally in /var/lib/mysql which is already mounted outside the container.
My final docker.cnf file is as follows:
[mysqld]
skip-host-cache
skip-name-resolve
bind-address = 0.0.0.0binlog-ignore-db = mysql
replicate-ignore-db = mysqllog_bin = /var/log/mysql/mysql-bin.log
relay-log = replication-1
server_id = 1Note: server_id = 2 on the replication slave.
Also note that without the relay-log option the command SHOW MASTER STATUS; returned no results on the master database container.
There is a possible outstanding issue yet which is that by default when you use docker stop it asks the container to terminate (by sending a SIGHUP to the docker entrypoint command) and if it doesn’t terminate within 10 seconds it is forcefully stopped. I need to ensure taht this is given sufficient time to shut down as it could take a little while to sort itself out while under load, possibly resulting in data loss as a result. -
2
0
Votes2
Posts0
ViewsC
In normal situation, mongodb uses always all available memory!!
However, you can limit mongo’s memory using cgroup.
Here is presentation what may help too. -
2
0
Votes2
Posts0
ViewsK
[Resolved]
What I did:version: «3.3»
services:
traefik:
image: «traefik:v2.0.0-rc3»
container_name: «traefik»
command:
— «—api.insecure=true»
— «—providers.docker=true»
— «—providers.docker.exposedbydefault=false»
— «—entrypoints.web.address=:80»
— «—defaultentrypoints=http,ws»
ports:
— «80:80»
— «8080:8080»
volumes:
— «/var/run/docker.sock:/var/run/docker.sock:ro» -
2
0
Votes2
Posts0
ViewsI finally solved it.After being around and helped by the user @JackNavaRow came out the solution.It was as simple as rebooting the system and erasing the volumes.Raise the containers and everything work ok.I’ll leave it here in case someone finds this problem, that doesn’t give him any more spins.EDITADOAnother possible mistake It’s putting inside en la parte de the database name but used the default name.I’d have to put…WORDPRESS_DB_NAME: wordpress
In this example the name is the default but if we had put another name in MYSQL_DATABASE: otro_nombre In case of not specifying in the wp-config as a database wordpress (by default)