https://pulumi.com logo
#general
Title
# general
b

brave-wall-78117

11/28/2022, 8:05 AM
Guys, I'm getting started with Pulumi using Docker and I'm getting an error for the volume path because I'm using a relative path instead of an absolute path. How do I not hardcode the path?
./redis/redis.conf
is within the Pulumi project. I tried using `HostPath = $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\redis\redis.conf",`but it exceeds the max path length of 255 and doesn't reach out that part.
dockerindexContainer (RedisContainer):
error: dockerindex/containerContainer resource 'RedisContainer' has a problem: './redis/redis.conf' must be an absolute path: './redis/redis.conf' must be an absolute path. Examine values at 'Container.Volumes'.
Copy code
return await Deployment.RunAsync(() =>
{
    var stackName = Deployment.Instance.StackName;
    const string redisHost = "redis";

    // Get configuration
    var config = new Pulumi.Config();
    var redisPort = config.RequireInt32("redisPort");

    // Create network
    var network = new Network("network", new NetworkArgs
    {
        Name = $"services-{stackName}"
    });

    // Find the latest redis image
    var redisImage = new RemoteImage("RedisImage", new RemoteImageArgs
    {
        Name = "redis:alpine"
    });

    // Start a container
    var redisContainer = new Container("RedisContainer", new ContainerArgs
    {
        Name = $"redis-{stackName}",
        Image = redisImage.Latest,
        Ports = new InputList<ContainerPortArgs>
        {
            new ContainerPortArgs
            {
                Internal = redisPort,
                External = redisPort
            }
        },
        Command = new InputList<string>
        {
            "redis-server /usr/local/etc/redis/redis.conf --requirepass mypassword"
        },
        Volumes = new InputList<ContainerVolumeArgs>
        {
            new ContainerVolumeArgs
            {
                HostPath = "./redis/redis.conf",
                ContainerPath = "/usr/local/etc/redis/redis.conf"
            }
        },
        NetworksAdvanced = new InputList<ContainerNetworksAdvancedArgs>
        {
            new ContainerNetworksAdvancedArgs
            {
                Name = network.Name,
                Aliases = new[]
                {
                    redisHost
                }
            }
        },
    });

    // Export
    return new Dictionary<string, object?>
    {
        ["redisContainer"] = redisContainer.Name
    };
});
s

shy-arm-32391

11/28/2022, 7:16 PM
hi @brave-wall-78117 - I'm fairly certain that for volume mounts, this is a limitation coming from Docker itself sad panda : https://github.com/moby/moby/issues/4830
b

brave-wall-78117

11/28/2022, 8:53 PM
problem solved. The issue was that I had to split the strings under
Command
on newlines
thanks anyway!