network: do not attempt to create a network in rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #871 Approved by: mheon
This commit is contained in:
		
							parent
							
								
									3861098fb3
								
							
						
					
					
						commit
						c976d49805
					
				| 
						 | 
				
			
			@ -512,6 +512,9 @@ func (c *Container) completeNetworkSetup() error {
 | 
			
		|||
	if !c.config.PostConfigureNetNS {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	if os.Getuid() != 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	if err := c.syncContainer(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -360,7 +360,11 @@ func (c *CreateConfig) GetContainerCreateOptions() ([]libpod.CtrCreateOption, er
 | 
			
		|||
	// does not have one
 | 
			
		||||
	options = append(options, libpod.WithEntrypoint(c.Entrypoint))
 | 
			
		||||
 | 
			
		||||
	if c.NetMode.IsContainer() {
 | 
			
		||||
	if os.Getuid() != 0 {
 | 
			
		||||
		if !c.NetMode.IsHost() && !c.NetMode.IsNone() {
 | 
			
		||||
			options = append(options, libpod.WithNetNS(portBindings, true))
 | 
			
		||||
		}
 | 
			
		||||
	} else if c.NetMode.IsContainer() {
 | 
			
		||||
		connectedCtr, err := c.Runtime.LookupContainer(c.NetMode.ConnectedContainer())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, errors.Wrapf(err, "container %q not found", c.NetMode.ConnectedContainer())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue