導航:首頁 > 文件管理 > 配置文件截位

配置文件截位

發布時間:2023-04-10 07:19:59

A. 易語言,關於配置文件的所有命令有哪些參數名分別有哪些最好展開後截圖或舉例!

配置文件就兩個命令 寫配置項() 和 讀配置項()

寫配置項(配置文件名,節點名,配置項名稱,欲寫入值)
讀配置項(配置文件名,節點名,配置項名稱, )

配置文件名 = 路徑 比如 取現行目錄+"\setup.ini"

節點名 = [設置]
配置項名稱 = 當前數字

setup.ini 文件內容如下:
---------------------------------------
[設置]
當前身高= 277
當前性別= 男
---------------------------------------

寫配置項(取現行目錄+"\setup.ini","設置","當前身高","277")

採用上面的提交項目就可以向setup.ini 寫入 ,但注意寫出的數字是文本的,不是數字型,你需要打引號或者採用轉換方式如 到文本(277)

當你要讀出來的時候就使用如

當前文本 = 讀配置項(取現行目錄+"\setup.ini","設置","當前身高", )

注意讀出的時候不用寫最後的答案,因為是讀取進軟體內,而不是寫出.也要注意的是讀入的數值什麼的也是文本型,注意轉換成數值,當然如果本身就是文本類型的就不需要轉換了,如
性別 = 讀配置項(取現行目錄+"\setup.ini","設置","當前性別", )

性別 = 男

B. 文件名過長 如何修改截位

修改截位的方法:
1、首先在需要刪除猛源的如知拍文件或者文件夾上面滑鼠右鍵,渣羨執行壓縮至文件操作;
2、然後將壓縮文件的命名為比較簡單的名字,並勾選「壓縮後刪除源文件」,然後點擊「確定」;
3、壓縮完成後,以前的文件已經刪除掉了,然後將壓縮文件刪除即可;

C. 配置至少三個配置文件的umask值為027,將配置截圖並說明是哪個配置文件

沒有腔扒效果,一般只是當前shell中有效伍輪昌。 除非修改配桐裂置文件/etc/bashrc,每次登錄後,bash才會調用裡面的設置。

D. outlook的配置文件在哪裡

Outlook怎樣新建配置文件?


當Outlook發送錯誤時,我們可以通過重新創建新的配置文件來重新載入數據。下面讓我們一起來看操作方法:

在桌面左下角單擊「開始」按鈕,彈出的菜單窗口單擊「控制面板」

E. .NET 配置文件:為什麼這么做,存放在何處,如何使用求答案

我想如果我提供一個對這些文件的快速入門會對大家有些幫助。 在本文章中,許多 C# 源碼例子都假設你的項目已經引用了 System.Configuration.dll 和引用了下面的命名空間: using System.Configuration; 這是使用ConfigurationManager類所必須的,而這個類提供了一種使用配置信息的方法。 Why The .NET framework provides a rich set of classes, and techniques, to simplify application configuration. Essentially, all of these classes make it easy to read and write that configuration information from an XML configuration file. The configuration file includes a number of standard sections, some custom sections for common .NET features, and also allows the developer to create their own custom configuration sections. The standard sections have evolved over time. Initially, standard configuration was done mostly through theappSettingssection, which contains name / value pairs for each setting. Over time, transparent, type-safe support was provided via a generated C#Settingsclass and the sections. 譯者信息為什麼NET框架提供了一套豐富的類和技術,以簡化應用配置。從本質上講,所有這些類可以很容易地從XML配置文件的讀取和寫入,配置信息。配置文件包含了.net程序中的一些標準的以及自定義的節點,並且也允許開發者創建自己的配置節點。標准節點隨著時間跟以前比有了很大的改變。最開始的時候,標准節點主要是配置應用程序的配置內容,比如為一個屬性一個屬性或者一個值。隨著時間的推移,它也為類型安全提供了支持,同時可以生成C#標準的配置信息以及用戶自定義的配置信息
Where Where do I find the configuration file? This is a deceptively complicated problem. Since configuration is hierarchical, there are actually multiple configuration files that may affect an application. These include the machine configuration file, the application (or web) configuration file, the user local settings file, and the user roaming settings file. Machine Configuration The machine configuration file lives with the, not so easily found, .NET framework files. The location of the configuration file is dependent on the version of .NET and type of platform (e.g. 64 bit) used by your application. A typical example, might be: C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\machine.config In your C# application code, the following will return the location of the file: System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"CONFIG\machine.config"譯者信息
何處 我從哪裡找到配置文件?這是一個迷惑性的復雜問題。自從配置文件分層後,有多個配置文件可能影響一個應用程序。這包括機器的配置文件,應用程序(或者網頁)配置文件,用戶本地設置文件,用戶的Roaming設置文件。 機器配置 和.NET框架文件一起的機器配置文件,並不是很容易找到。配置文件的位置還取決於.NET的版本和應用程序使用的平台(比如,64位) 一個典型的例子就是
C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\machine.config 在你的C#應用程序代碼中,下面的語句將會返迴文件的位置: System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"CONFIG\machine.config" Application Configuration The application configuration file usually lives in the same directory as your application. For web applications, it is named Web.config. For non-web applications, it starts life with the name of App.config. Following a build, it is copied to the same name as your .exe file. So, for the program MyProgram.exe, you might expect to find MyProgram.exe.config, in the same directory. In your C# application code, the following will return the location of the file: AppDomain.CurrentDomain.SetupInformation.ConfigurationFile While it is not generally recommended, you may find that some applications alter the location of the application configuration file as follows: AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "NewName.config")譯者信息
應用配置文件
應用程序配置文件一般跟你的應用程序存在於相同的目錄下面。對於web應用程序來說,它的名字是Web.config,而對一般的應用程序來說,它的名字是App.config。在一個項目下,它的名字格式與你的.exe文件相似。比如你的工程名字是MyProgram.exe,那麼你就可以在相同的路徑下找到MyProgram.exe.config。 在你的C#應用程序源代碼中,使用下面的代碼可以返迴文件的路徑: AppDomain.CurrentDomain.SetupInformation.ConfigurationFile 如果它不是被經常調用,你可以做在應用程序的配置文件中做一些小的修改。下面是例子: AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "NewName.config") User Settings The user settings are almost impossible to find, perhaps by design. The names of the directories vary with versions of Windows. To complicate matters further, the parent folder is generally hidden. The folder structure also incorporates the company name (of the application vendor), the application name, a unique identity for the application, and the application version. An example, on Windows 7, for local user settings might look like: C:\Users\MyUsername\AppData\Local\CompanyName\MyProgram.exe_Url_\1.0.0.0\user.config In C#, you can get the base directory for local user settings (first line) or roaming user settings (second line) as follows: Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) In C# (see notes in Overview), you can get the exact file path for local user settings (first line) or roaming user settings (second line) as follows: ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming).FilePath譯者信息
用戶設置 用戶設置大多數時候不好找,這很可能是處於設計的原因。目錄的名字因Windows版本而異。更復雜的是父目錄通常是隱藏的。. 目錄結構加入了公司名稱(應用程序的供應商),應用程序名稱,應用程序唯一ID號和應用程序的版本。 舉個例子,在Windows7下,一個本地用戶設置可能像這樣: C:\Users\MyUsername\AppData\Local\CompanyName\MyProgram.exe_Url_\1.0.0.0\user.config 在C#中,你可以獲得本地用戶設置的基目錄(第一行)或者臨時用戶設置(第二行): Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) 在C#中, (見在概述中的注記),你可以獲得本地用戶設置的解壓文件路徑(第一行)或者roaming用戶設置(第二行): ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming).FilePath Other Configuration If this isn't all confusing enough, you should be aware of a few other files. There is a root Web.config (located in the same directory as machine.config). Also, sub-directories of a web application may provide additional overrides of inherited settings, via a Web.config specific to that sub-directory. Lastly, IIS provides some of its own configuration. A typical location would be: C:\Windows\System32\inetsrv\ApplicationHost.config How As mentioned earlier, the application configuration file is broken into a number of fairly standard configuration sections. Here, we briefly discuss a few of the most common sections. 譯者信息
其它配置 如果這還不夠混亂,那你應該知道其它的一些文件了(這個不會翻譯)。有個原始的Web.config文件(與machine.config同一個目錄下)。此外,子目錄下面的Web應用程序可能會通過子目錄裡面的Web.config重寫繼承(於父目錄的Web.config)的設置。 此外,IIS提供了一些自己的配置。一個典型的例子位置在: C:\Windows\System32\inetsrv\ApplicationHost.config 如何 正如前面提到的,應用程序配置文件被分解成若乾的相當標准配置部分。在這里,我們簡要地討論一下一些最常見的部分。 appSettings Section The simplest of the standard configuration sections isappSettings, which contains a collection of name / value pairs for each of the settings: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="MySetting" value="MySettingValue" /> </appSettings> </configuration> In C# (see notes in Overview), you can reference the value of a setting as follows: string mySetting = ConfigurationManager.AppSettings["MySetting"]; connectionStrings Section Since database connections are so common in .NET, a special section is provided for database connection strings. The section is calledconnectionStrings: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="MyConnectionStringName" connectionString="Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> In C#, you can get the connection string as follows: string connectionString = ConfigurationManager.ConnectionStrings[ "MyConnectionStringName"].ConnectionString; Initially, one might wonder at the need to reference aConnectionStringproperty of a "connection string". In truth, the connectionStrings section is poorly named. A better name might have beenconnectionStringSettings, since each entry contains both a connection string and a database provider. The syntax of a connection string is wholly determined by the database provider. In this caseSystem.Data.SqlClient, is the most common database provider for the Microsoft SQL Server database. 譯者信息
appSettings 部分 最簡單的標准設置部分就是 appSettings 了,這個部分包含了一系列保存配置的 鍵/值 對。 <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="MySetting" value="MySettingValue" /> </appSettings> </configuration> 在C#中(見附註概述),你可以通過下面方式引用對應配置的值: string mySetting = ConfigurationManager.AppSettings["MySetting"]; connectionStrings 部分 由於資料庫連接在.NET中相當普遍,一個特別用於提供資料庫連接字元串的部分產生了。這個部分就是 connectionStrings。 <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="MyConnectionStringName" connectionString="Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> 在C# 中,你可以通過下面方式去獲取連接字元串: string connectionString = ConfigurationManager.ConnectionStrings[ "MyConnectionStringName"].ConnectionString; 起初人們可能會奇怪在需要引用一個"connection string"屬性作為連接字元串。說實話,這個connectionStrings部分的名字真不恰當。叫做"connectionStringSettings"會更恰當,因為(部分_裡面的每個實體夠包含了連接字元串和database provider(資料庫提供者)。 一個連接字元串的語法完全取決於其database provider。 因此 System.Data.SqlClient 是Microsoft SQL Server最典型的database provider。 applicationSettings and userSettings Section With .NET 2.0, Microsoft tried to make it even easier to use configuration files. They introced a settings file. A careful observer will note that the "settings" start their life in the application configuration file and, later, get copied to the user settings configuration file. With Windows Form and WPF applications, you'll find a file Settings.settings in the Properties folder of your project. For Console applications, and others, you can also take advantage of settings. Open the Properties for your project, and click on the Settings button/tab. You'll be offered the option of adding a default settings file. Typically, you edit this settings file (or the settings for your project) rather than editing the configuration file directly. The example below is provided only to demonstrate that the settings do actually live in the configuration file. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="WinFormConfigTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="WinFormConfigTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> <WinFormConfigTest.Properties.Settings> <setting name="MyUserSetting" serializeAs="String"> <value>MyUserSettingValue</value> </setting> </WinFormConfigTest.Properties.Settings> </userSettings> <applicationSettings> <WinFormConfigTest.Properties.Settings> <setting name="MyApplicationSetting" serializeAs="String"> <value>MyApplicationSettingValue</value> </setting> </WinFormConfigTest.Properties.Settings> </applicationSettings> </configuration> To reference one of the settings, you simply use theSettingsclass, which is automatically created for you. A typical reference, might look as follows: string myUserSetting = Properties.Settings.Default.MyUserSetting; string myApplicationSetting = Properties.Settings.Default.MyApplicationSetting; Note:Propertiesis a namespace that is automatically created in your application's name space. To change a user's settings, you simply assign a value to the property and save the changes, as follows: Properties.Settings.Default.MyUserSetting = newValueForMyUserSetting; Properties.Settings.Default.Save();譯者信息
applicationSettings 和 userSettings 部分 在.NET 2.0 中,微軟嘗試讓用戶更容易使用設置文件。他們為此引入了設置文件。細心的觀察者可能會注意到這些"settings"開始用於應用程序配置文件,並且在後面復制到用於配置文件中。 在Windows Form和WPF程序中,你可以在你的項目的Properties目錄下找到一個名為Settings.settings的文件。對於控制台程序還有其它程序,可以通過下面方式使用配置文件。打開你的項目中屬性,切換到 設置 選項,你可以通過這里為項目添加一個配置文件。 通常情況下,你可以編輯此設置文件(或者是你的項目設置)來修改配置,而不是直接編輯(.config)配置文件。下面的例子演示了設置在配置文件中如何存儲。 <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="WinFormConfigTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="WinFormConfigTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> <WinFormConfigTest.Properties.Settings> <setting name="MyUserSetting" serializeAs="String"> <value>MyUserSettingValue</value> </setting> </WinFormConfigTest.Properties.Settings> </userSettings> <applicationSettings> <WinFormConfigTest.Properties.Settings> <setting name="MyApplicationSetting" serializeAs="String"> <value>MyApplicationSettingValue</value> </setting> </WinFormConfigTest.Properties.Settings> </applicationSettings> </configuration> 當你想引用設置的時候,你可以簡單的引用Settings類,這個類會自動為你創建。下面是一個典型的引用方式: string myUserSetting = Properties.Settings.Default.MyUserSetting; string myApplicationSetting = Properties.Settings.Default.MyApplicationSetting; 注意:Properties 命名空間會自動的創建在你的應用程序的命名空間下。 要改變用戶設置時,你只需像下面一樣為屬性賦予一個值然後保存就可以了: Properties.Settings.Default.MyUserSetting = newValueForMyUserSetting; Properties.Settings.Default.Save(); Upgrading Settings Eventually, you'll want to release a new version of your application. Here, you may encounter a common problem. Since the user settings are version specific, they will be lost following the upgrade. Thankfully, the framework anticipates this requirement and provides theUpgrademethod. A typical way of handling this is to include a booleanUpgradeser setting, with an initial value of false (when your application is first deployed). So, typical code to handle the upgrade (and retain previous user settings) looks as follows: if (!Properties.Settings.Default.Upgraded) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Upgraded = true; Properties.Settings.Default.Save(); }譯者信息
更新設置 實際上,當你想發布一個新版本的程序時,你可能會遇到的一個普遍問題。由於用戶設置是有特定版本的,程序升級會導致這些設置丟失。 值得慶幸的是,框架預預料到這種情況並提供了一個更新設置的方法。一個典型的處理辦法是引入一個初始值為false的用戶設置「Upgraded」(當你首次部署你的程序)。 因此,用來處理升級的典型代碼(並保留以前的用戶設置)如下所示: if (!Properties.Settings.Default.Upgraded) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Upgraded = true; Properties.Settings.Default.Save(); } What Next In the previous section, you may have noticed the rather verboseconfigSectionssection of the configuration file. This is how Microsoft extended the configuration file to add the new userSettings and applicationSettings sections. It is also how you can add your own custom configuration sections. In a nutshell, you do this by extending . Within each of your derived classes, you will be decorating the members with attributes . Simple right? Just kidding. Others have provided excellent descriptions of this slightly complicated, but not too difficult mechanism. I include links at the end of this document for further reading. Here, I only wanted to provide a couple of hints that can get lost in the longer descriptions. 譯者信息
下一步做什麼 在前一部分,你可能注意到了配置文件相當冗長的configSections。這也是微軟如何拓展配置文件,用來添加新的用戶設置和應用設置。 它也是你如何來添加你自己定製的配置的區塊。 簡而言之,你通過拓展 類來完成的。在你的每一個繼承的類里,你會用類似這樣的屬性來布置你的類成員。 很簡單,對嗎?開個玩笑。對於其他的,已經提供了很好很詳細,稍微有點復雜的描述,和不是很難理解的機制。我會在這篇文檔的末尾添加這些鏈接供進一步閱讀。 這里,我只想提供一些在冗長描述中會感到困惑的提示。

F. 配置文件位於目錄什麼中,文件名以什麼開始

配置文件通常位於應用程序或操作系統的安裝目錄中,以及用戶目錄下的特桐含定目錄渣謹中。文件名通常以「.」或「config」等關鍵字開始,示例包括:

- .bashrc
- .gitconfig
- .vimrc
- config.ini
- settings.json
- application.properties

具體的配置文件路徑如輪基和名稱取決於不同的軟體或操作系統,需要查看相關文檔或設置界面來確認。

G. dnswindows配置文件位置

配置文件的位置肯定都是在系統的文件夾裡面,一般來說都是WINDOWS或system 32這樣的一個系統

H. 如何從Docker Registry中導出鏡像

一、目錄結構

Registry的配置文件中可以指定registry的運行目錄(實驗用本地文件系統作為後端存儲),registry會在這個目錄中建立相應的目錄結構,我在本地啟動一個registry服務,然後只push一個centos鏡像上去。鏡像名稱是localhost:5000/library/centos:latest,然後registry在本地創建了如圖1所示的目錄。

圖 1 registry目錄

為了顯示方便,我只截取了64位ID的前一部分。可以看到,目錄大體分為兩個:一個是blobs,一個是repositories。blobs中主要存放數據文件,可以看出都是經過sha256計算後的ID。repositories目錄中放鏡像的描述信息,記錄了一個鏡像有哪些layer,tag對應的manifest文件,link文件是一個文本文件,內容是一個形如「sha256:cf34a09a90b54c…」的64位ID,這個ID對應在blob中的文件其實就是這個image的manifest文件。

二、Manifest文件

manifest文件描述了一個鏡像的元信息,包括了layer的數據ID,layer的配置等,文件格式是json形式的文本文件。

docker鏡像可以分為V1和V2,在1.9以後鏡像格式有一些變化。為了向前兼容V1版本的docker,docekr
registryV2使用的manifest也對應地分為Schema1和Schema2,兩者可以通過官方對於manifest的解釋可以參考[1]和[2]。這里實驗都是在schema1上做的。

Schema1主要包含如下信息:

name:image的倉庫(repository)名,比如localhost:5000/library/centos:latest這個鏡像的repository name是library/centos
tag:該鏡像的tag
architecture:指該鏡像的宿主機的操作系統架構,如「amd64」
fsLayers:該欄位是一個數組,數組中的元素分別指明了各層對應的數據文件的sha256ID,數組的第1個就是鏡像的最頂層,第2個是次頂層…以此類推,值得注意的是,不同層的fsLayer
ID
有可能一樣,是因為有些層是空的,只有一些配置信息。當執行了一個不涉及文件操作的命令,這時候就會形成空fsLayer,空fsLayer計算出來的sha256ID也都是一樣的了。鏡像的一個layer,是由文件系統(比如新增的文件)fsLayer以及配置信息構成的,layer在docker的代碼層面又被稱為image,因為任意一個layer都可以作為頂層layer,被docker
image信息引用,從而成為一個image。所以需要區分fsLayer與layer。
history:該欄位也是一個數組,是為了兼容v1而設置的,指明了每個layer的配置信息,數組第一項對應賀御的是鏡像的最頂層,與fslayer一起構成了一個layer。數組元素是一個json格式的map對象,key為「v1Compatibility」,值為一個字元串,該字元串就是layer的配置信息,可以直接用json.Unmrashal成為一個V1Image結構體(定義可以參考代碼github.com/docker/docker/image/image.go
L31)
schemaVersion:該manifest的版本,一個int型,如 1。

三、Tar包形式的鏡像

Docker中有個save和load命令。save命令可以將一個docker鏡像導出,把這個鏡像從最頂層到最底層的所有layer一起導出到一個tar包中,然後就可以隨意拷貝、發送這個tar包到別的機器,最後可以用load命令把這個鏡像重新載入進docker。

如果我們把一個鏡像從registry里拿出來,按照save成的tar包格式來組耐拍困織,然後使用load命令載入,這樣就實現了不通過docker pull命令來下載鏡像,可以根據這個原理做第三方鏡像下載工具

所以我們先來看一下鏡像的tar包形式是什麼樣的,我使用save命令導出了centos鏡像,解壓後目錄結構如圖2所示:

圖 2 鏡像tar包解壓後的目錄

下昌念面對各文件進行解釋:

根目錄下的repositories文件,描述了這個鏡像的名字,tage,還有頂層layer的id

不同的文件夾代表了不同的layer。

json:layer的配置信息,如創建時間,執行命令等。

layer.tar:layer中包含的文件,如果是空layer,layer.tar解壓後就是空的。

VERSION: 版本信息。

四、從registry導出鏡像

我們對比tar包中的文件和registry中的文件,不難發現其中的對應關系,json、VERSION還有repositories文件都是可以從manifest中導出。

json文件其實就是之前提到的history欄位中v1Compatibilitiy,不同的是manifest中的這個欄位中有很多轉義符,我們需要去掉這些轉義符,方法是先Unmarshal成為一個V1Image結構體,然後在json.Marshal轉回字元串就好。

layer.tar其實就是blobs中對應的data文件,直接復制出來然後改個名字就可以。

VERSION是manifest中的schemaVersion。

repositories文件內容很簡單,格式是{「imageName」:{「tag」:」topLayerID」}},所以按照這個格式從manifest中找到對應的數據填進去就ok。

這些文件都准備好了以後,就可以准備打包成tar包了,直接使用linux中自帶的tar命令,這里需要注意的一點是,應該使用「只打包不壓縮」的選項。生成tar包後就可以直接使用docker load命令導入了。

我這么做了,是可以成功地導入一個鏡像。但是發現存在一個問題:使用上述方式導入的鏡像,每個layer的ID和我直接用docker
pull命令下載下的不一樣,而且docker
pull得到的ID從未在manifest和registry中的任何地方出現過。而且不管我使用新的機器還是重新pull,得到的ID都是一樣的。經過閱讀docker的代碼我才發現,layerID不是隨機生成的,也不是manifest中寫道的id,而是算出來的。下面就說一下計算過程。

我們最終需要的layerID在docker源碼中叫做StrongID,StrongID是把一個byte數組做Hash後得到的,這個byte數組的生成需要三個對象:v1Compatibility,blobSum(manifest中的fsLayerID),parent(父layer的StrongID),數組生成方法參考image.go中的MakeImageConfig方法(docker
1.9),基本操作就是把一個json對象轉成位元組數組。因為有parent欄位的存在,需要從最底層的layer開始計算,逐步迭代,最終的到top
layer的ID。最後要做的工作就是替換json文件中的id欄位和parent欄位成為新計算出來的ID即可。同樣地,文件夾名也要做相應改變。

增量導入:如果本地已經存在某些layer的情況,我們只用打包新的layer即可,因為導入時候docker會檢測這個layer是否存在,而且有parent信息來保證layer之間的關系。

I. Windows下,Vim的配置文件(_vimrc)在哪

在vim中輸入如下命令

可以看到版本信息,其中包含我們要找的配置文件的位置:

接下來的問題就是,這些變數所代表的路徑了:

使用以下命令來查詢:

(在我的機器上)得到的結果分別是

J. shell腳本中,我要在配置文件寫入東西,但是截取的內容可能沒有,我想如果沒有填入其他的東西

A=`awk ......`
如果是空,就賦值你想填入的其他東西
if [ -z $A ];then
A='123.123.123.123'
fi

閱讀全文

與配置文件截位相關的資料

熱點內容
慧信app下載的文件在哪裡 瀏覽:541
手機qq個性名片卡通 瀏覽:987
熊貓反詐app哪裡能下載 瀏覽:485
口袋靈獸安卓 瀏覽:999
如何打好堅實的編程基礎 瀏覽:230
蘋果電腦文件怎麼壓小 瀏覽:896
崑山文件加密軟體 瀏覽:609
桌面文件轉發到移動硬碟 瀏覽:961
怎樣更改像素和壓縮文件 瀏覽:322
dos打開文件路徑 瀏覽:935
文件被隱藏了怎麼辦 瀏覽:677
win10回收站文件找回 瀏覽:750
手機數據如何恢復到最新的 瀏覽:153
丹青文件管理系統激活 瀏覽:604
迷你編程第一關卡住怎麼辦 瀏覽:658
少兒編程編程貓和猿編程哪個好 瀏覽:318
windows更新完後哪些文件可以刪 瀏覽:107
華為鎖屏密碼忘記 瀏覽:845
抖音平台數據從哪裡看 瀏覽:820
打開文件夾出錯 瀏覽:825

友情鏈接