mirror of
				https://github.com/containers/podman.git
				synced 2025-10-31 18:08:51 +08:00 
			
		
		
		
	 65a618886e
			
		
	
	65a618886e
	
	
	
		
			
			Add a new "image" mount type to `--mount`. The source of the mount is the name or ID of an image. The destination is the path inside the container. Image mounts further support an optional `rw,readwrite` parameter which if set to "true" will yield the mount writable inside the container. Note that no changes are propagated to the image mount on the host (which in any case is read only). Mounts are overlay mounts. To support read-only overlay mounts, vendor a non-release version of Buildah. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
		
			
				
	
	
		
			75 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package docker
 | |
| 
 | |
| import (
 | |
| 	"io"
 | |
| 	"net/http"
 | |
| )
 | |
| 
 | |
| // AttachToContainerOptions is the set of options that can be used when
 | |
| // attaching to a container.
 | |
| //
 | |
| // See https://goo.gl/JF10Zk for more details.
 | |
| type AttachToContainerOptions struct {
 | |
| 	Container    string    `qs:"-"`
 | |
| 	InputStream  io.Reader `qs:"-"`
 | |
| 	OutputStream io.Writer `qs:"-"`
 | |
| 	ErrorStream  io.Writer `qs:"-"`
 | |
| 
 | |
| 	// If set, after a successful connect, a sentinel will be sent and then the
 | |
| 	// client will block on receive before continuing.
 | |
| 	//
 | |
| 	// It must be an unbuffered channel. Using a buffered channel can lead
 | |
| 	// to unexpected behavior.
 | |
| 	Success chan struct{}
 | |
| 
 | |
| 	// Override the key sequence for detaching a container.
 | |
| 	DetachKeys string
 | |
| 
 | |
| 	// Use raw terminal? Usually true when the container contains a TTY.
 | |
| 	RawTerminal bool `qs:"-"`
 | |
| 
 | |
| 	// Get container logs, sending it to OutputStream.
 | |
| 	Logs bool
 | |
| 
 | |
| 	// Stream the response?
 | |
| 	Stream bool
 | |
| 
 | |
| 	// Attach to stdin, and use InputStream.
 | |
| 	Stdin bool
 | |
| 
 | |
| 	// Attach to stdout, and use OutputStream.
 | |
| 	Stdout bool
 | |
| 
 | |
| 	// Attach to stderr, and use ErrorStream.
 | |
| 	Stderr bool
 | |
| }
 | |
| 
 | |
| // AttachToContainer attaches to a container, using the given options.
 | |
| //
 | |
| // See https://goo.gl/JF10Zk for more details.
 | |
| func (c *Client) AttachToContainer(opts AttachToContainerOptions) error {
 | |
| 	cw, err := c.AttachToContainerNonBlocking(opts)
 | |
| 	if err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	return cw.Wait()
 | |
| }
 | |
| 
 | |
| // AttachToContainerNonBlocking attaches to a container, using the given options.
 | |
| // This function does not block.
 | |
| //
 | |
| // See https://goo.gl/NKpkFk for more details.
 | |
| func (c *Client) AttachToContainerNonBlocking(opts AttachToContainerOptions) (CloseWaiter, error) {
 | |
| 	if opts.Container == "" {
 | |
| 		return nil, &NoSuchContainer{ID: opts.Container}
 | |
| 	}
 | |
| 	path := "/containers/" + opts.Container + "/attach?" + queryString(opts)
 | |
| 	return c.hijack(http.MethodPost, path, hijackOptions{
 | |
| 		success:        opts.Success,
 | |
| 		setRawTerminal: opts.RawTerminal,
 | |
| 		in:             opts.InputStream,
 | |
| 		stdout:         opts.OutputStream,
 | |
| 		stderr:         opts.ErrorStream,
 | |
| 	})
 | |
| }
 |