-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DockerComposeCompositeService.ExtractNames fails for container names with other format #94
Comments
Hi what name does For example, given this docker-compose.yaml file version: "3"
services:
wordpress:
image: visiblevc/wordpress
cap_add:
- SYS_ADMIN
devices:
- /dev/fuse
security_opt:
- apparmor:unconfined
ports:
- 8080:80
- 443:443
volumes:
- ./data:/data
- ./scripts:/docker-entrypoint-initwp.d
- ./plugins/skelleftetekniken-contest:/app/wp-content/plugins/skelleftetekniken-contest
depends_on:
- db
links:
- db
environment:
DB_NAME: wordpress
DB_PASS: root
PLUGINS: >-
academic-bloggers-toolkit
co-authors-plus
wp-file-manager
[WP-API]https://github.com/WP-API/WP-API/archive/master.zip
URL_REPLACE: localhost:8080
WP_DEBUG: 'true'
WP_DEBUG_DISPLAY: 'true'
WP_DEBUG_LOG: 'true'
db:
image: mysql:5.7
volumes:
- data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 22222:80
volumes:
data:
where
How are you firing up the containers and what names do they get? Cheers, |
With docker-compose.yml version: '3.5'
services:
# building up the message queue system (zookeeper + kafka)
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
networks:
- messageBus
ports:
- "2181:2181"
restart: always
kafkaserver:
image: wurstmeister/kafka
container_name: kafka
networks:
- messageBus
ports:
- 9092:9092
- 29092:29092
- 29093:29093
restart: always
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST_DEMOSRV:PLAINTEXT,PLAINTEXT_LOCALHOST:PLAINTEXT
KAFKA_LISTENERS: PLAINTEXT://:9092,PLAINTEXT_HOST_DEMOSRV://:29092,PLAINTEXT_LOCALHOST://:29093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST_DEMOSRV://demo01:29092,PLAINTEXT_LOCALHOST://localhost:29093
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
# overrides the default separator ',' for creating topics
KAFKA_CREATE_TOPICS_SEPARATOR: "$$'\n'"
# create topic "Values" that will use log compaction to get rid of older value messages
KAFKA_CREATE_TOPICS: |
Values:1:1:compact --config=min.compaction.lag.ms=250 --config=segment.bytes=536870912 --config=segment.ms=10000 --config=retention.ms=10000 --config=min.cleanable.dirty.ratio=0.25 --config=file.delete.delay.ms=0
Configuration:1:1:delete --config=file.delete.delay.ms=0 --config=retention.bytes=-1 --config=retention.ms=-1
ProjectDefinition:1:1:delete --config=file.delete.delay.ms=0 --config=retention.bytes=-1 --config=retention.ms=-1
SetValues:1:1:delete --config=retention.ms=1000 --config=segment.ms=1000 --config=segment.bytes=268435456 --config=min.cleanable.dirty.ratio=0.1 --config=file.delete.delay.ms=0
Devices:1:1:delete --config=file.delete.delay.ms=0 --config=retention.bytes=-1 --config=retention.ms=-1
ReadHistoryValues:1:1:delete --config=retention.ms=1000 --config=segment.ms=1000 --config=segment.bytes=268435456 --config=min.cleanable.dirty.ratio=0.1 --config=file.delete.delay.ms=0
# Enables/disables the possibility to delete a topic (if set to false, the topic will only be marked for deletion but not deleted actually)
KAFKA_DELETE_TOPIC_ENABLE: "true"
networks:
default:
external:
name: nat
# create network for messaging
messageBus:
name: message-bus and starting up with docker-compose:
I guess the |
This fix is when the docker-compose specifies a container name explicit and thus do not use the project_service_instanceId pattern. It will use the label instead to dig out the project and instance id (the name will be the set container name).
@msdeibel I've fixed the issue using the labels on the containers as fallback when container name is set explicitly. The following unittest now works (with your docker-compose file). var file = Path.Combine(Directory.GetCurrentDirectory(),
(TemplateString) "Resources/ComposeTests/KafkaAndZookeeper/docker-compose.yaml");
using (var svc = Fd.UseContainer()
.UseCompose()
.FromFile(file)
.Build()
.Start())
{
var kafka = svc.Services.OfType<IContainerService>().Single(x => x.Name == "kafka");
var zookeeper = svc.Services.OfType<IContainerService>().Single(x => x.Name == "zookeeper");
Assert.AreEqual("kafkaandzookeeper",kafka.Service);
Assert.AreEqual("kafkaandzookeeper",zookeeper.Service);
Assert.AreEqual("1",kafka.InstanceId);
Assert.AreEqual("1",zookeeper.InstanceId);
} Cheers, |
Pushed to nuget 2.7.1 (it will take a while before the packages get indexed). |
Works like charm with the NuGet 2.7.1 package. Thanks :) |
private static string ExtractNames(Container container, out string project, out string instanceId)
fails when called with a container name likekafka
.The result is a ArrayIndexOutOfBoundsException in line 155.
It expects a structure like
project_component1_instanceId
as name.Why this structure is expected is not clear from looking at the method itself.
Also this is not a naming convention from Docker.
I do not have a patch since I don't know what the expected behaviour should be in case of a name that deviates from the structure currently expected by the method.
The text was updated successfully, but these errors were encountered: